Locate missing cells
Audit tabular data before cleaning or validation.
Pandas · Module
Detect missing values in a DataFrame by returning a same-sized boolean mask. Missing entries are True, while other entries are False; isnull() is an alias for isna().
Calling isnull() examines every cell and produces a same-shaped boolean DataFrame. Missing values become True; other values become False. It is an alias of isna(), so either spelling provides the same result.
DataFrame.isnull()A boolean DataFrame of the same size, with True for missing values and False otherwise.
True in the corresponding output cells.False.isna() method.import pandas as pd
frame = pd.DataFrame({
"name": ["Ada", None, "Linus"],
"score": [95, 88, None],
})
missing = frame.isnull()
print(missing)
Creates a boolean DataFrame marking the missing entries in each original cell.
Audit tabular data before cleaning or validation.
Build boolean filters for incomplete records.
Quantify missingness by field.
It returns a boolean DataFrame with the same dimensions as the input. Each position is True when its corresponding value is considered missing and False otherwise.
Follow-up: How would you count missing values per column? Use frame.isnull().sum(); boolean values are summed column-wise.
isnull() and isna() are aliases, so they have equivalent behavior. The choice is mainly a naming preference or a consistency decision within a codebase.
Follow-up: How can you test whether an entire row has at least one missing value? Apply .any(axis=1) to the boolean result.
Values such as None and numpy.NaN are mapped to True, while non-missing values map to False. The output preserves the DataFrame's shape, allowing masks to be applied directly to the original data.
Follow-up: How can you select only rows containing missing data? Use frame[frame.isnull().any(axis=1)].
pandas.DataFrame.isnapandas.isnullpandas.isna