.isnull()与.isna()熊猫相比。
示例代码:
import pandas as pd
import numpy as np
df = pd.DataFrame({ 'object': ['a', 'b', 'c',pd.NA],
'numeric': [1, 2, np.nan , 4],
})
创建如下所示的数据框df:
| | object | numeric | categorical |
|---:|:---------|----------:|:--------------|
| 0 | a | 1 | d |
| 1 | b | 2 | nan |
| 2 | c | nan | f |
| 3 | <NA> | 4 | g |
测试.isnull()和.isna():
pd.isnull(df.iloc[3,0])
Out[165]: True
pd.isnull(df.iloc[2,1])
Out[166]: True
pd.isna(df.iloc[3,0])
Out[167]: True
pd.isna(df.iloc[2,1])
Out[168]: True
在这里两者都.isnull()给出.isna()相同的结果。
问题:与 pandas 一起使用哪一个以及为什么要使用?他们每个人与熊猫的主要优点和缺点是什么?