dropna
DataFrame.dropna(axis=0, how=‘any’, thresh=None, subset=None, inplace=False)
axis:确定删除确实的行或列,默认是0代表列,1代表行。
how:any,all,any代表存在True就是True,all代表全部是True才是True。
thresh:设置非缺失值数量阈值,小于阈值的删除。
subset:设置参考的列
inplace:是否修改原始数据
import pandas as pd
df = pd.DataFrame({"one":[1, 2, np.nan,np.nan], "two":[np.nan, 3, 4,np.nan],'three':[np.nan,np.nan,np.nan,np.nan]})
print('1:',df.dropna(axis=0, how='all'))
print('2:',df.dropna(axis=0, how='any'))
print('3:',df.dropna(thresh=2))
print('4:',df.dropna(subset=['one','two'],thresh=2))