pandas dataframe drop columns by number of nan

后端 未结 5 820
忘了有多久
忘了有多久 2021-01-04 02:08

I have a dataframe with some columns containing nan. I\'d like to drop those columns with certain number of nan. For example, in the following code, I\'d like to drop any co

5条回答
  •  旧巷少年郎
    2021-01-04 02:16

    Say you have to drop columns having more than 70% null values.

    data.drop(data.loc[:,list((100*(data.isnull().sum()/len(data.index))>70))].columns, 1)
    

提交回复
热议问题