0
0
Pandasdata~5 mins

Detecting missing values with isna() in Pandas

Choose your learning style9 modes available
Introduction

We use isna() to find missing or empty data in tables. This helps us clean and understand our data better.

When you want to check if any data is missing in a survey results table.
Before analyzing sales data, to find where values are not recorded.
To identify empty cells in a dataset before filling or removing them.
When cleaning data from sensors that sometimes fail to record values.
Syntax
Pandas
DataFrame.isna()

This returns a table of the same shape with True where data is missing and False where data is present.

You can use it on a whole DataFrame or on a single column (Series).

Examples
Check missing values in the entire DataFrame df.
Pandas
df.isna()
Check missing values only in the 'Age' column.
Pandas
df['Age'].isna()
Count how many missing values are in each column.
Pandas
df.isna().sum()
Sample Program

This code creates a small table with some missing values. Then it shows where the missing values are with True and counts how many missing values each column has.

Pandas
import pandas as pd

data = {'Name': ['Alice', 'Bob', None, 'David'],
        'Age': [25, None, 22, 23],
        'City': ['New York', 'Los Angeles', 'Chicago', None]}

df = pd.DataFrame(data)

missing = df.isna()
print(missing)

missing_count = df.isna().sum()
print(missing_count)
OutputSuccess
Important Notes

isna() treats None and NaN as missing values.

You can also use isnull() which works the same as isna().

Summary

isna() helps find missing data easily.

It returns a table of True/False showing missing spots.

Counting missing values helps decide how to clean data.