当前位置:网站首页>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))
边栏推荐
- torchvision.datasets.ImageFolder前的数据整理及使用方法
- Array - 977. Square of ordered array
- [unity3d daily bug] unity3d solves "the type or namespace name" XXX "cannot be found (are you missing the using directive or assembly reference?)" Etc
- Crazy God redis notes 10
- How to reasonably estimate the size of thread pool
- 1000个Okaleido Tiger首发上线Binance NFT,引发抢购热潮
- 系列文章|云原生时代下微服务架构进阶之路 - 微服务拆分的最佳实践
- Introduction and project development of MVVM and mvvmlight (I)
- STM32+ESP8266+MQTT协议连接阿里云物联网平台
- Explain NAT technology in detail
猜你喜欢
随机推荐
FL Studio 20.9 update Chinese version host Daw digital audio workstation
Wangxuegang video coding -- mediacodec coding and decoding
Crazy God redis notes 10
Lu Xia action | Source Kai Digital: Existing Mode or open source innovation?
【golang学习笔记】并发基础
How to reasonably estimate the size of thread pool
砺夏行动 2022|源启数字化圆桌论坛即将上线
About synchronizing data from computer to mobile
Mongodb - Introduction to the use of $exists and the combination of $ne, $nin, $nor, $not in query statements
TAP 系列文章6 | TAP的应用模型
[Matplotlib drawing]
Investment suggestions for overseas senior players (3) 2021-05-04
MySQL的 DDL和DML和DQL的基本语法
Drools (1): introduction to drools
Rails搭配OSS最佳实践
砺夏行动|源启数字化:既有模式,还是开源创新?
1000个Okaleido Tiger首发上线Binance NFT,引发抢购热潮
软件测试工作内容太简单怎么办?
El upload realizes the preview of uploaded files
激光雷达点云数据录制的rosbag文件转换成csv文件









