Pandas isnull() and notnull() Method (original) (raw)

Last Updated : 31 Oct, 2025

Missing or null values are common in real-world datasets. Pandas provides isnull() and notnull() to detect such values in a DataFrame or Series.

These methods are essential for locating, filtering, or counting missing values during data cleaning.

To download the csv file used in this article, click here

Detecting Missing Values with isnull()

isnull() identifies NULL or NaN values and returns a boolean Series or DataFrame.

**Syntax:

pd.isnull(obj)

**Parameters:

**Example:

Python `

import pandas as pd

data = pd.read_csv(r'enter the path to dataset here')

bool_series = pd.isnull(data["Team"]) missing_values_count = bool_series.sum() filtered_data = data[bool_series]

print("Count of missing values in 'Team':", missing_values_count) print("Rows with missing 'Team':") print(filtered_data)

`

**Output

21

**Explanation:

Detecting Non-Missing Values with notnull()

notnull() method is the inverse of isnull(). It identifies non-missing (valid) values.

**Syntax:

pd.notnull(obj)

**Parameters:

**Example:

Python `

import pandas as pd data = pd.read_csv(r'enter path to dataset here') bool_series = pd.notnull(data["Gender"]) filtered_data = data[bool_series]

print(filtered_data)

`

**Output

22

**Explanation:

Filtering Data Based on Null Values

You can combine isnull() and notnull() for efficient filtering in data cleaning tasks.

**Syntax:

pd.notnull(obj)

**Parameters:

**Example:

Python `

import pandas as pd

data = pd.read_csv("employees.csv") bool_series = pd.notnull(data["Gender"]) filtered_data = data[bool_series] print("Data with non-null 'Gender' values:") print(filtered_data)

`

**Output

23

**Explanation: