Open In App

Pandas Index.isna()

Last Updated : 24 Jun, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

Index.isna() function in pandas detects missing values i.e., NaN or None in a pandas.Index. It behaves identically to Index.isnull(), as both are aliases of each other. It returns a boolean array, where:

  • True indicates a missing value.
  • False indicates a valid (non-null) value.

Example:

Python
import pandas as pd
import numpy as np

idx = pd.Index(['a', None, 'c', 'd'])
print(idx.isna())

Output
[False  True False False]

Syntax

Index.isna()

Parameters: This method does not take any parameters.

Returns: A NumPy boolean array indicating missing values. It returns True for missing values such as NaN or None and False for valid (non-missing) values.

Examples

Example 1: In this example, we filter only the null values from the Index using boolean indexing.

Python
import pandas as pd
import numpy as np

idx = pd.Index([10, 20, np.nan, 40])
null_values = idx[idx.isna()]
print(null_values)

Output
Index([nan], dtype='float64')

Explanation: This filters out only the null (np.nan) values from the Index. The dtype becomes float64 because of the presence of nan.

Example 2: In this example, we verify that isna() and isnull() are functionally equivalent.

Python
import pandas as pd
import numpy as np

idx = pd.Index([None, 5, np.nan])
print(idx.isna() == idx.isnull())

Output
[ True  True  True]

Explanation: All elements return True, confirming isna() and isnull() are functionally identical.

Example 3: In this, we check if all values in the Index are null using .all().

Python
import pandas as pd
import numpy as np

idx = pd.Index([None, np.nan])
print(idx.isna().all())

Output
True

Explanation: All values are missing, so isna().all() returns True.

Example 4: In this, we check if any value in the Index is null using .any().

Python
import pandas as pd
import numpy as np

idx = pd.Index([1, 2, np.nan])
print(idx.isna().any())

Output
True

Explanation: At least one value (np.nan) is missing, so it returns True.


Similar Reads