Skip to main content
v2026.11,986 entries · CC-BY 4.0

pandas isna: Detect Missing Values (isna vs isnull)

How pandas isna() and isnull() detect missing values, what they miss, and how to count and filter gaps in research data.

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

  1. Load the data, for example df = pd.read_csv("study.csv").
  2. Flag missing cells. df.isna() returns a DataFrame of booleans with the same shape as df. On a Series, pd.Series([5, 6, np.nan]).isna() returns False, False, True with dtype bool.
  3. Count per column. Because True sums as 1, df.isna().sum() gives the number of missing values in each column. This is a standard pandas idiom built on isna(), not a separate method.
  4. Express it as a proportion. df.isna().mean() gives the fraction missing per column, which is easier to compare across variables.
  5. Find the affected rows. Use the Series form as a boolean mask: df[df["age"].isna()] keeps only rows where age is missing. df[df.isna().any(axis=1)] keeps rows with a missing value in any column, and df[df.notna().all(axis=1)] keeps complete rows.
  6. 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

Follow CASRAI

Research-administration guidance, standards updates and independent tool reviews.

Ask CASRAI · free to try

Ask about pandas isna: Detect Missing Values (isna vs isnull)

2 free questions a day, no account.

An AI assistant for research: funder rules, compliance, methods and publishing. It links the sources behind its answers and labels answers that come from a web search.

Answers draw on CASRAI's guides and dictionary plus the federal and funder documents we index: Federal Register, Grants.gov, Regulations.gov and UKRI.

Works on this site and inside Claude, Cursor and the AI tools you already use.

Everything CASRAI publishes — this page, the dictionary, the guides and the news — stays open to read, with no account and no card.

Referenced across the research world

University of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logoUniversity of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logo
  • University of Cambridge logo
  • Columbia University logo
  • Crossref logo
  • University of Edinburgh logo
  • Harvard University logo
  • University of Oxford logo
  • Princeton University logo
  • Stanford School of Medicine logo
  • University College London logo
  • ORCID logo

View CASRAI adoption →