How to drop column according to NAN percentage for dataframe?

后端 未结 3 960
深忆病人
深忆病人 2020-11-28 10:49

For certain columns of df, if 80% of the column is NAN.

What\'s the simplest code to drop such columns?

3条回答
  •  自闭症患者
    2020-11-28 11:08

    df.dropna(thresh=np.int((100-percent_NA_cols_required)*(len(df.columns)/100)),inplace=True)
    

    Basically pd.dropna takes number(int) of non_na cols required if that row is to be removed.

提交回复
热议问题