Detecting Missing Values (isna, notna, isnull)0%
Detecting Missing Values (isna, notna, isnull)
Beginner12 min read•Updated: Jul 11, 2026
Detecting Missing Values (isna, notna, isnull)
Reading Time: 8 Mins | Level: Beginner to Advanced
1. What is Missing Data in Pandas?
Real-world datasets are almost never 100% complete. In Pandas, missing data is represented as:
np.nan(Not a Number, a special IEEE floating-point value)pd.NA(Pandas' modern experimental nullable missing indicator)None(Standard Python null object, automatically cast to NaN in numeric columns)
Real-world Analogy: Jaise exam me kisi student ki attendance sheet par blank space reh jati hai ya registration form me phone number fill nahi kiya gaya hota, wahi Pandas me NaN kehlata hai.
2. Detecting Missing Data: .isna() vs .isnull()
In Pandas, .isna() and .isnull() are 100% identical aliases. .isna() is preferred because it matches the modern scientific terminology (is NA).
Python
import pandas as pd
import numpy as np
df = pd.DataFrame({
'Name': ['Amit', 'Sunita', np.nan, 'Rohan', 'Sneha'],
'Age': [24, np.nan, 29, 31, np.nan],
'Salary': [50000, 62000, 58000, np.nan, 67000]
})
print(df.isna())
Output (Boolean Matrix):
Output
Name Age Salary
0 False False False
1 False True False
2 True False False
3 False False True
4 False True False
3. Summarizing Missing Data Across Columns
To compute the exact number and percentage of nulls in each column:
Python
# 1. Count of missing values per column
missing_counts = df.isna().sum()
print("Missing counts:\n", missing_counts)
# 2. Percentage of missing values
missing_pct = (df.isna().sum() / len(df)) * 100
print("\nMissing Percentage:\n", missing_pct)
Output:
Output
Missing counts:
Name 1
Age 2
Salary 1
dtype: int64
4. Filtering Rows with or without Missing Data
df[df['Salary'].isna()]: Find all rows where Salary is missing.df[df['Name'].notna()]: Keep only rows where Name is present.
Interactive Quiz
Multiple Choice Questions
Question 1
What is the standard representation of missing floating-point values in Pandas?
Question 2
What is the difference between
df.isna() and df.isnull()?Question 3
Which code snippet returns the total count of missing values in each column?
Question 4
Which method is the logical opposite of
df.isna(), returning True for valid non-null entries?Question 5
Why can direct equality comparison like
np.nan == np.nan not be used to check for missing values?Next Lesson
Dropping & Filling Missing Values (dropna, fillna)
Continue learning with hands-on practice, examples, and exercises in the upcoming topic.
Related Lessons
| Previous Lesson | Next Lesson |
|---|---|
| Setting, Resetting & Managing Indices | Dropping & Filling Missing Values (dropna, fillna) |
Practice Quiz
Test your understanding of this lesson with 5 questions. Each question has one correct answer.