Pandas 中可以使用以下方法來判斷空值:
-
df.isnull()
:返回一個布爾類型的數(shù)據(jù)框,表示各個位置是否是空值。 -
df.isna()
:與df.isnull()
等價。 -
df.notnull()
:與df.isnull()
相反,返回一個布爾類型的數(shù)據(jù)框,表示各個位置是否不是空值。文章來源:http://www.zghlxwxcb.cn/news/detail-631070.html
例如:文章來源地址http://www.zghlxwxcb.cn/news/detail-631070.html
import pandas as pd
df = pd.DataFrame({'A': [1, 2, np.nan, 4],
'B': [5, np.nan, 7, 8],
'C': [9, 10, 11, 12]})
print(df.isnull())
print(df.notnull())
到了這里,關(guān)于pandas 判斷空值的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!