Skip to content
masterclass Buddy

Pandas · Method

df.where

DataFrame.where keeps values where a condition is true and replaces other values. You can provide a scalar, aligned data, or callable as the replacement.

Last updated

Syntax

DataFrame.where(cond, other=<no_default>, *, inplace=False, axis=None, level=None)

In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.

Subscribe
  • DataFrame.mask()
  • Series.mask()

Source: pandas.DataFrame.where — pandas 3.1.0 documentation. Checked 2026-11-03.