Select rows from a DataFrame based on presence of null value in specific column or columns Select rows from a DataFrame based on presence of null value in specific column or columns pandas pandas

Select rows from a DataFrame based on presence of null value in specific column or columns


I think you need isnull for checking NaN values with boolean indexing:

df[df['Easting'].isnull()]

Docs:

Warning

One has to be mindful that in python (and numpy), the nan's don’t compare equal, but None's do. Note that Pandas/numpy uses the fact that np.nan != np.nan, and treats None like np.nan.

In [11]: None == NoneOut[11]: TrueIn [12]: np.nan == np.nanOut[12]: False

So as compared to above, a scalar equality comparison versus a None/np.nan doesn’t provide useful information.

In [13]: df2['one'] == np.nanOut[13]: a    Falseb    Falsec    Falsed    Falsee    Falsef    Falseg    Falseh    FalseName: one, dtype: bool