当前位置:网站首页>None和nan、NaN、NAN
None和nan、NaN、NAN
2022-07-23 22:51:00 【MallocLu】
总结
None是Python中表示空数据的对象,nan、NaN、NAN是numpy中表示空数据的对象(其中pandas读取Excel时空数据使用的是nan)
# nan、NaN、NAN的判断
isnan(t)
t != t
# None的判断
isinstance(t, type(None))
not t
测试
from math import isnan
from numpy import nan, NaN, NAN
# True True True
print(isnan(nan), isnan(NaN), isnan(NAN))
# TypeError: must be real number, not NoneType
print(isnan(None))
# <class 'float'> <class 'float'> <class 'float'>
print(type(nan), type(NaN), type(NAN))
# <class 'NoneType'>
print(type(None))
# False False False
print(nan == nan, NaN == NaN, NAN == NAN)
# True
print(None == None)
# 不满足
if not nan:
print('nan')
# 满足
if not None:
print('None')
# True True True
print(id(nan) == id(nan), id(NaN) == id(NaN), id(NAN) == id(NAN))
# True
print(id(None) == id(None))
边栏推荐
- 【golang学习笔记】flag包的简单使用,命令行解析
- The font of Siyuan notes is thinner and lighter than that in other editors (atom, VSC, sublime)
- Array - 11. Containers with the most water
- Debian | Can’t locate Debian/Debhelper/Sequence/germinate. pm in @INC
- 小说里的编程 【连载之十七】元宇宙里月亮弯弯
- 1000 okaleido tiger launched binance NFT, triggering a rush to buy
- Raspberry pie SSH login
- As a developer, you have to know the three performance testing tools JMeter, API and jmh user guide
- Programming in the novel [serial 17] the moon bends in the yuan universe
- STM32单片机使用ADC功能驱动手指检测心跳模块
猜你喜欢

Drools (1): introduction to drools

Ways to improve the utilization of openeuler resources 01: Introduction

The ultimate experiment of OSPF -- learn the example of OSPF century template
The font of Siyuan notes is thinner and lighter than that in other editors (atom, VSC, sublime)

Introduction and project development of MVVM and mvvmlight (I)
关于电脑端同步到手机端数据

Internet协议栈 TCP/IP模型 物理层、链路层、网络层、传输层、应用层的作用

Array - 59. Spiral matrix II

Memory search - DP

Excel password related
随机推荐
[Matplotlib drawing]
synthesizable之Verilog可不可综合
Explain NAT technology in detail
[problem handling] merge made by the 'ort' strategy
$, $*, [email protected], $$ Understand the meaning of 0
Crazy bull market, where to go in the second half? 2021-04-30
Matlab wavelet toolbox import signal error (doesn't contain one dimensional single)
20. Valid parentheses valid parentheses
D1-H 开发板——哪吒 开发入门
Remember an experience of being cheated by the Internet
VIM common shortcut keys
torchvision.datasets.ImageFolder前的数据整理及使用方法
Lu Xia action | Source Kai Digital: Existing Mode or open source innovation?
Debian | Can’t locate Debian/Debhelper/Sequence/germinate. pm in @INC
Tap series article 4 | backstage based tap developer portal
小说里的编程 【连载之十八】元宇宙里月亮弯弯
巴菲特股东大会的启示 2021-05-06
Programming in the novel [serial 20] the moon bends in the yuan universe
TAP 系列文章5 | 云原生构建服务
TAP 系列文章8 | TAP 学习中心——通过动手教程来学习