4

I have dataframe like below.

Input

df A B C 1 2 1 NaN 4 2 3 NaN NaN NaN NaN NaN 4 2 NaN NaN NaN NaN 

Output

 A B C 1 2 1 NaN 4 2 3 NaN NaN 4 2 NaN 

How can this be done in python

0

3 Answers 3

6
df.dropna(axis = 0, how = 'all') 
Sign up to request clarification or add additional context in comments.

Comments

3

you can use:

df.dropna(how='all') 

you can look into this thread also: How to drop rows of Pandas DataFrame whose value in a certain column is NaN

Comments

-1

You can select the df which is not NaN rather than dropping it:

df = df[~((df['A'].isna()) & (df['B'].isna()) & (df['C'].isna()))] 

This gives a bit more capability if you want to filter your df by certain values of each column.

A B C 1 2 1 NaN 4 2 3 NaN NaN 4 2 NaN 

You can use df.dropna?? to get the information about the dropna functionality.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.