Build a boolean mask to select missing entries.
Filtering
Pandas · Function
Detect whether a scalar or array-like object contains missing values. Scalars return one boolean, while array-like inputs return corresponding boolean indicators.
pd.isna tests a scalar or array-like object for missing values. Scalars produce one boolean; array-like inputs produce a matching boolean structure, preserving the input type for Series and DataFrame objects.
pandas.isna(obj)| Name | Type | Description |
|---|---|---|
obj | scalar or array-like | Object to check for null or missing values. |
bool or array-like of bool
pd.isna to create missing-value indicators for scalar or array-like data.bool result.import numpy as np
import pandas as pd
values = pd.Series([1, None, np.nan, "ok"])
print(pd.isna(values).tolist())
print(pd.isna("ok"))
print(pd.isna(pd.NA))Creates a boolean Series mask for missing elements and returns scalar booleans for scalar inputs.
Filtering
Validation
Data cleaning
pandas.isna return?pd.isna(obj) identifies missing values in scalars and array-like inputs. A scalar returns a boolean, while an array-like input returns boolean indicators for corresponding elements.
Follow-up: How does the result differ for a DataFrame? It returns a same-shaped DataFrame containing boolean missingness indicators.
pandas.isna detect?The function recognizes NaN in numeric arrays, None or NaN in object arrays, and NaT in datetimelike values. It therefore provides a common missing-value test across several pandas data representations.
Follow-up: What should be used to identify non-missing values? Use the documented inverse operation, pandas.notna.
The required argument is obj, described as a scalar or array-like object to check for null or missing values. The function accepts one object and does not require additional arguments.
Follow-up: How can missing rows be selected from a Series? Apply the resulting boolean mask, for example series[pd.isna(series)].
pandas.notnapandas.isnullpandas.DataFrame.isnapandas.Series.isna