Written and maintained by CASRAI Editorial Board
Published
On this page
pandas isna() returns a boolean object of the same shape that is True wherever a value is missing and False everywhere else. isnull() is an alias for it, and notna() is its boolean inverse. Analysts use it to count, locate and filter missing values before any statistics are computed (checked against the pandas documentation on 2026-11-08, which displays version 3.1.1).
What pandas isna is used for in research data
Survey, assay and registry datasets nearly always contain gaps. Before modelling, you need to know which variables have gaps, how many, and whether the gaps are real missing values or placeholder codes. isna() answers the first two questions directly; the troubleshooting section below covers the third. Once you know the pattern, dropna() in pandas removes labels with missing values, and the wider workflow is covered in data cleaning steps.
isna vs isnull
There is no behavioural difference. The pandas reference states that DataFrame.isnull is an alias of DataFrame.isna, so df.isnull() and df.isna() return identical results. Pick one and use it consistently within a project.
What counts as missing
According to the DataFrame.isna reference, characters such as empty strings '' or numpy.inf are not considered NA values. None and numpy.nan are. The pandas missing-data user guide lists the missing-value markers by data type:
| Marker | Used with | Detected by isna() |
|---|---|---|
np.nan |
NumPy dtypes | Yes |
None |
object columns | Yes |
NaT |
datetime64, timedelta64, PeriodDtype | Yes |
pd.NA |
StringDtype, Int64Dtype (and other nullable integer dtypes), Float64Dtype, BooleanDtype, ArrowDtype | Yes |
Empty string '' |
text | No |
numpy.inf |
floats | No |
Source for every row: the two pandas pages linked above, read 2026-11-08.
Install or access
pandas is free, open-source software distributed by the project at pandas.pydata.org; follow the installation page there for the supported methods. The examples below assume the conventional imports:
import numpy as np
import pandas as pd
Step-by-step: find and count missing values
- Load the data, for example
df = pd.read_csv("study.csv"). - Flag missing cells.
df.isna()returns a DataFrame of booleans with the same shape asdf. On a Series,pd.Series([5, 6, np.nan]).isna()returnsFalse, False, Truewith dtypebool. - Count per column. Because
Truesums as 1,df.isna().sum()gives the number of missing values in each column. This is a standard pandas idiom built onisna(), not a separate method. - Express it as a proportion.
df.isna().mean()gives the fraction missing per column, which is easier to compare across variables. - Find the affected rows. Use the Series form as a boolean mask:
df[df["age"].isna()]keeps only rows whereageis missing.df[df.isna().any(axis=1)]keeps rows with a missing value in any column, anddf[df.notna().all(axis=1)]keeps complete rows. - Decide what to do. Hand off to
dropna(), or fill or model the gaps; that choice depends on your study design, not on pandas.
The scalar and array form: pd.isna()
The top-level function pandas.isna(obj) accepts a scalar or array-like. A scalar returns a single bool; an array returns an array of bools; a Series or DataFrame returns the same type. The reference examples show pd.isna("dog") is False, while pd.isna(pd.NA) and pd.isna(np.nan) are True. Use this form for single values, for instance inside a function applied with pandas map.
Worked example: what isna() sees and misses
This frame mirrors the structure of the official documentation example (a numeric column, a datetime column, a text column with an empty string, and a column with None):
df = pd.DataFrame({
"age": [5, 6, np.nan],
"born": [pd.NaT, pd.Timestamp("1939-05-27"), pd.Timestamp("1940-04-25")],
"name": ["Alfred", "Batman", ""],
"toy": [None, "Batmobile", "Joker"],
})
df.isna()
Per the pandas reference, the result is True for age in the third row, for born in the first row and for toy in the first row. Every name cell is False, including the empty string in the last row.
Output and how to read it
- Same shape, boolean dtype. Index and column labels carry over, so the result lines up with the original for masking.
- Counts.
df.isna().sum()returns an integer Series indexed by column name. - Proportions.
df.isna().mean()returns floats between 0 and 1. - Zero does not mean complete. A column with zero missing values may still hold empty strings or numeric placeholder codes, which
isna()does not detect.
Troubleshooting
Comparing with == np.nan finds nothing
The pandas user guide states that equality comparisons with np.nan, NaT and NA do not provide useful information about missing data. Use isna() (or notna()) instead of df["age"] == np.nan.
Empty strings are not flagged
Because '' is not NA, convert it first: df["name"].replace("", np.nan). Re-run isna() on the result.
Placeholder codes such as -99 are not flagged
Questionnaire codebooks often use numeric codes like -99 for “no answer”. pandas treats them as ordinary numbers. If your codebook defines them as missing, convert them with df.replace(-99, np.nan) before counting. Convert only codes your data dictionary defines as missing; a value such as -99 can be legitimate in some measures.
Infinite values
Because numpy.inf is not NA, check for it separately, for example with np.isinf(df["x"]). Related behaviour of NaN in NumPy arrays is covered in NumPy NaN.
FAQ
What is the difference between pandas isna and isnull?
None. isnull is an alias of isna, per the pandas DataFrame reference.
Does isna() treat empty strings as missing?
No. Empty strings and numpy.inf are not considered NA values.
How do I count missing values per column?
Chain .sum(): df.isna().sum(). Use .mean() for proportions.
How do I keep only rows where a column is missing?
Use the mask df[df["col"].isna()]. Use notna() to keep the rest.
What is the opposite of isna()?
notna(), the boolean inverse of isna().
Sources
- pandas.DataFrame.isna, pandas documentation (read 2026-11-08)
- pandas.isna, pandas documentation (read 2026-11-08)
- Working with missing data, pandas user guide (read 2026-11-08)







