pandas.Index.where
pandas 3.1.1 · Index objects · method
Keep values where a condition is true and replace the rest with the supplied alternative.
Call syntax
Index.where(cond, other=None)Run the example
Edit the example and select Run Python to see the result.
Parameters
| Parameter | Requirement | Accepted values and behavior |
|---|---|---|
cond |
Required Positional or keyword |
bool array-like with the same length as self Provide a condition or callable producing a boolean mask. |
other |
Optional Positional or keyword Default None |
scalar, or array-like Supply the second object or value used in the operation. |
Returns
pandas.Index