Home > front end >  How to check if multiple columns have only nan values & remove that column
How to check if multiple columns have only nan values & remove that column

Time:07-25

How to check if multiple columns are Empty( entries in a column = 0) only and remove them.

Here's the preview of a dataset

enter image description here

It has 8932 columns and 27884 rows. user_iD is index.

I need to find out which of the columns in the dataframe are empty and remove those columns from the dataframe

Moreover since the dataframe has more than 8K columns , I cant check each of them manually if the column is empty or not

So far what I have tried is only these lines which do not serve my purpose

data.isnull().sum()

CodePudding user response:

Try this

data.dropna(axis=1, how='all')
  • Related