知識點:dropna()
df1 = df.dropna(axis=0,subset = ['b'])
(過濾掉b列有缺失的行,注意:若缺失值為空字符串則無法過濾)
詳解:
Signature: df.dropna(axis=0, how='any', thresh=None, subset=None, inplace=False)
axis : {0 or 'index', 1 or 'columns'}, default 0
0, or 'index':刪除包含丟失值的行
1, or 'columns':刪除包含丟失值的列
默認為0
how : {'any', 'all'}, default 'any'
'any': 如果存在NA值,則刪除該行或列
'all': 如果所有值都是NA,則刪除該行或列
thresh: int,保留含有int個非空值的行
subset: 對特定的列進行缺失值刪除處理
示例: