pandas.Series.case_when
pandas 3.1.1 · Series and accessors · method
Choose replacements using a sequence of condition–value pairs. If multiple conditions match, the first match wins.
Call syntax
Series.case_when(caselist)Run the example
Edit the example and select Run Python to see the result.
Parameters
| Parameter | Requirement | Accepted values and behavior |
|---|---|---|
caselist |
Required Positional or keyword |
A list of tuples of conditions and expected replacements |
Returns
Series