Finding Missing Values
isna finds missing values. A missing value is an empty cell, shown as NaN.
isna marks the gaps
Only the Coffee price is missing, so only row 1 is True.
import pandas as pd
df = pd.DataFrame({
"product": ["Tea", "Coffee", "Mug"],
"price": [4.50, None, 12.00],
})
print(df["price"].isna())Keep only the rows with a gap
The mask keeps the one row with a missing price.
import pandas as pd
df = pd.DataFrame({
"product": ["Tea", "Coffee", "Mug"],
"price": [4.50, None, 12.00],
})
print(df[df["price"].isna()])notna marks the filled cells
notna is the opposite of isna. It keeps the two rows with a price.
import pandas as pd
df = pd.DataFrame({
"product": ["Tea", "Coffee", "Mug"],
"price": [4.50, None, 12.00],
})
print(df[df["price"].notna()])Example
import io
import pandas as pd
SALES_CSV = """order_id,date,product,category,units,price,region
101,2026-01-05,Tea,Drink,2,4.50,North
102,2026-01-06,Coffee,Drink,1,6.00,South
103,2026-01-07,Mug,Home,3,12.00,East
104,2026-01-08,Notebook,Office,2,8.50,West
105,2026-01-09,Pen,Office,5,2.00,North
106,2026-01-12,Lamp,Home,1,24.00,South
107,2026-01-13,Tea,Drink,4,4.50,East
108,2026-01-14,Coffee,Drink,2,6.00,West
109,2026-01-15,Mug,Home,1,12.00,North
110,2026-01-16,Notebook,Office,3,8.50,South
111,2026-01-19,Pen,Office,2,2.00,East
112,2026-01-20,Lamp,Home,2,24.00,West"""
sales = pd.read_csv(io.StringIO(SALES_CSV))
sales.loc[2, "price"] = None
print(sales[sales["price"].isna()])Key points
- Use isna on a column to mark the gaps with True.
- Use notna to mark the filled cells with True.
- NaN is the mark of a missing value.
- A mask from isna filters the table down to the rows with gaps.
- isna and notna never change the table. They only report where the gaps are.
In this example, the sales table is read from the CSV text. The Mug price is set to None, which makes it missing. isna marks that row True, and the filter keeps only that row.
Try it Yourself
Edit the code, then press Run.
Running is simulated · Python Playground
Exercise
Which method returns True for missing values?