Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Pandas · Module

df.notnull

Detects which DataFrame elements are non-missing. It returns a same-sized boolean DataFrame, with True for present values and False for recognized NA values.

How it works

Call DataFrame.notnull() to produce a same-shaped boolean DataFrame: each non-missing element becomes True, while recognized missing values become False. It is an alias of DataFrame.notna() and preserves the DataFrame’s labels and dimensions.

Syntax

DataFrame.notnull()

Returns

DataFrame: A boolean mask with the same shape, whose elements indicate whether corresponding values are not NA.

Key points

  • The method tests every DataFrame element for whether it is present rather than missing.
  • Its result has the same dimensions as the source and contains boolean indicators.
  • Present entries become True in the returned mask.
  • Recognized missing entries, including None and numpy.NaN, become False.
  • The method is an alternate name for DataFrame.notna() and has equivalent behavior.

Common mistakes

  • Empty strings and positive or negative infinity are treated as present values, so this method will mark them True.

Example: Check non-missing DataFrame values

import numpy as np
import pandas as pd

df = pd.DataFrame({
    "age": [5, 6, np.nan],
    "name": ["Alfred", "Batman", ""],
    "toy": [None, "Batmobile", "Joker"],
})

mask = df.notnull()
print(mask)
print(df[mask["age"]])

Creates a boolean mask for existing values and uses one column of that mask to keep rows with a known age.

When to use it

Identify present values

Build a validity mask before filtering, validation, or conditional updates.

Filter rows by completeness

Select records whose required field is populated using boolean indexing.

Audit data quality

Inspect missingness patterns across columns while retaining the original DataFrame layout.

Interview questions

QWhat does DataFrame.notnull() return?

It returns a boolean DataFrame with the same shape and labels as the input. Each value is True when it is not recognized as missing and False when it is NA.

Follow-up: How would you retain only rows with a present value in one column? Use the resulting boolean Series as a row mask, for example df[df["column"].notnull()].

QHow does notnull() relate to notna()?

DataFrame.notnull() is an alias for DataFrame.notna(), so both methods perform the same missing-value test. The method operates element by element across the DataFrame.

Follow-up: What is the complementary operation? DataFrame.isna() identifies missing values, making its boolean result the inverse test for this operation.

QHow are missing and non-missing elements represented?

Values such as None and numpy.NaN are mapped to False, while existing values are mapped to True. The output remains a DataFrame rather than collapsing to one overall truth value.

Follow-up: How can the mask be used for selection? Combine it with boolean indexing, or apply reductions such as any() or all() when a row- or column-level result is needed.

  • DataFrame.notna
  • DataFrame.isna
  • DataFrame.isnull

Source: pandas.DataFrame.notnull — pandas 3.0.6 documentation. Checked 2026-10-15.