Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pandas DataFrame select the specific columns with NaN values

I have a two-column DataFrame, I want to select the rows with NaN in either column.

I used this method df[ (df['a'] == np.NaN) | (df['b'] == np.NaN) ]
However it returns an empty answer. I don't know what's the problem

like image 921
Fan Avatar asked Jul 14 '16 07:07

Fan


1 Answers

You need isnull for finding NaN values:

df[ (df['a'].isnull()) | (df['b'].isnull()) ]

Docs.

like image 190
jezrael Avatar answered Oct 22 '22 23:10

jezrael