isna() / isnull() (Pandas)

df.isna() returns a boolean DataFrame the same shape as the original, marking True wherever a value is missing (NaN, NaT, or None). isnull() is an exact alias. Use it to detect and count missing data.

Pandas

Because you cannot test for NaN with == (NaN is not equal to anything, even itself), isna() is the correct way to find missing values. The boolean result is most useful chained with sum: df.isna().sum() counts the missing values per column in one line.

isna() and isnull() are identical — pandas keeps both names, one matching NumPy/R conventions and one matching SQL. Their opposite is notna() (alias notnull()), which marks the non-missing cells.

The boolean mask doubles as a filter: df[df['x'].isna()] selects the rows where x is missing, and df[df['x'].notna()] selects the complete ones.

Syntax

df.isna()  |  df.notna()  |  df.isna().sum()

Examples

Python

import pandas as pd, numpy as np
s = pd.Series([1.0, np.nan, 3.0])
print(s.isna())

Output:

0    False
1     True
2    False
dtype: bool

Learn it in a lesson

See also

Back to the Dictionary