Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to check if multiple columns have only nan values & remove that column

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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()

>Solution :

Try this

data.dropna(axis=1, how='all')
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading