pandas数据类型判断(三)数据判断
1.函数:缺失值判断
1)判断数值是否为空用 pd.isna,pd.isnull,np.isnan
2)判断字符串是否为空用 pd.isna,pd.isnull;
3)判断时间是否为空用 pd.isna,pd.isnull,np.isnat
参数:obj:标量或数组
返回:布尔或布尔数组
说明:
1.NA值如None或np.nan,NaT将映射True值。‘‘或np.inf不被视为NA值
2.pandas.options.mode.use_inf_as_na = True#视为na值
3.Series,DataFrame也有此方法;full,notfull是别名
4.pd.isna 是pandas0.21版本引入的,能判别最大范围的空值。
实例1:缺省值判断-标量参数
1.案例如下:
>>> pd.isna(None) True >>> >>> pd.isnull(None) True >>> >>> np.nan(None) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: ‘float‘ object is not callable >>> >>> np.isnat(None) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: ufunc ‘isnat‘ is only defined for datetime and timedelta.
2.
相关推荐
三石 2020-10-30
三石 2020-10-29
roamer 2020-10-29
wangquannuaa 2020-10-15
wangquannuaa 2020-09-29
jzlixiao 2020-09-15
wangquannuaa 2020-08-30
三石 2020-08-23
逍遥友 2020-08-21
jzlixiao 2020-08-18
wangquannuaa 2020-08-17
QianYanDai 2020-08-16
cjsyrwt 2020-08-14
jzlixiao 2020-07-29
xirongxudlut 2020-07-20
mmmjyjy 2020-07-16
QianYanDai 2020-07-05
QianYanDai 2020-07-05
june0 2020-07-04