isna()

noun

say it: “IZ en-AY” /ˈɪz ˌɛnˈeɪ/

A pandas method that checks each value and marks the missing ones True and the rest False.

What does isna() do in pandas?

isna() answers True for each missing value (NaN) and False for every value that's there. Because True counts as 1, isna().sum() gives how many values each column is missing.

import pandas as pd
intake = pd.read_csv("intake.csv", na_values=["unknown", "-"])
intake.isna().sum()     # name 70, breed 34, age_years 52, ...

In a sentence

  • “isna() followed by sum() counted the blanks in every column.”
  • “She used isna() to keep only the animals with no recorded age.”

Level: Apprentice · More Python terms at this level

Updated