Pandas Index.isnull()-Python
Last Updated :
24 Jun, 2025
Index.isnull() function in pandas detects missing values (NaN or None) in a pandas Index. It returns a boolean array where True indicates a missing value and 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.isnull())
Output[False True False False]
Explanation: Only the second value is None (null), so it's marked True. All other values are valid.
Syntax
Index.isnull()
Parameters: This method does not take any parameters.
Returns: A NumPy boolean array: True for missing values like NaN or None and False for valid ones.
Examples
Example 1: In this, 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_vals = idx[idx.isnull()]
print(null_vals)
OutputIndex([nan], dtype='float64')
Explanation: This filters out the null (np.nan) from the Index. The dtype becomes float because of the presence of nan.
Example 2: In this, we verify that isnull() is the logical opposite of notnull().
Python
import pandas as pd
import numpy as np
idx = pd.Index([None, 5, np.nan])
print(idx.isnull() == ~idx.notnull())
Explanation: Each element in the result is True, confirming both methods are logical opposites.
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.isnull().all())
Explanation: Every value in the Index is null, so isnull().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.isnull().any())
Explanation: Since there is at least one missing value (np.nan), the result is True.
Related articles: pandas
Similar Reads
Python | Pandas Index.isnull() Index.isnull() function in pandas detects missing values (NaN or None) in a pandas Index. It returns a boolean array where True indicates a missing value and False indicates a valid (non-null) value. Example:Pythonimport pandas as pd import numpy as np idx = pd.Index(['a', None, 'c', 'd']) print(idx
2 min read
Python | Pandas Index.isna() 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:Pythonimport pand
2 min read
Python | Pandas Index.isin() Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier. Pandas Index.isin() function return a boolean array where the index values are in valu
2 min read
Python | Pandas Index.notnull() Index.notnull() function in pandas detect non-missing (non-NaN/None) values within a pandas Index. It returns a boolean array where True indicates the element is valid (not null) and False indicates it is missing. Example: Pythonimport pandas as pd import numpy as np idx = pd.Index([1, 2, np.nan, 4]
2 min read
Python | Pandas Index.min() Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier. Pandas Index.min() function returns the minimum value of the Index. The function works
2 min read