0PricingLogin
Pandas & NumPy Academy · Lesson

Detecting Missing Values

Use isna(), notna(), and isnull() to find NaN locations in a Series or DataFrame and count missing values per column.

What Are Missing Values in Pandas?

In Pandas, a missing value is represented as NaN (Not a Number) for numeric columns and None or pd.NaT for datetime columns. Missing data is common in real-world datasets because records may be incomplete, sensors may fail, or joins may produce unmatched rows. Detecting missing values is always the first step in any data cleaning workflow.

Pandas normalises None, float('nan'), and numpy.nan to the same internal NaN representation for numeric columns.

import pandas as pd
import numpy as np

df = pd.DataFrame({
    'name': ['Alice', None, 'Carol'],
    'age': [25, np.nan, 30],
    'salary': [50000.0, 60000.0, np.nan]
})
print(df)
#     name   age   salary
# 0  Alice  25.0  50000.0
# 1   None   NaN  60000.0
# 2  Carol  30.0      NaN

isna() and isnull()

isna() and isnull() are completely identical — both return a DataFrame or Series of the same shape filled with True wherever the value is missing and False elsewhere. Pandas provides both names purely for user preference. The result can be used directly as a boolean mask for filtering or further computation.

import pandas as pd
import numpy as np

df = pd.DataFrame({
    'A': [1, np.nan, 3],
    'B': [np.nan, 2, np.nan]
})

print(df.isna())
#        A      B
# 0  False   True
# 1   True  False
# 2  False   True

# Both are identical
print((df.isna() == df.isnull()).all().all())  # True

All lessons in this course

  1. Detecting Missing Values
  2. Dropping Missing Values
  3. Filling Missing Values
  4. Interpolation and Advanced Imputation
← Back to Pandas & NumPy Academy