Suppose I have the following dataframe in df
:
a | b | c
------+-------+-------
5 | 2 | 4
NaN | 6 | 8
5 | 9 | 0
3 | 7 | 1
If I do df.loc[df['a'] == 5]
it will correctly return the first and third row, but then if I do a df.loc[df['a'] == np.NaN]
it returns nothing.
I think this is more a python thing than a pandas one. If I compare np.nan
against anything, even np.nan == np.nan
will evaluate as False
, so the question is, how should I test for np.nan
?