pandas.Categorical.map
pandas 3.1.1 · Arrays, scalars, and data types · method
Apply a substitution or callable to individual values. The receiver determines which mappers it supports.
Call syntax
Categorical.map(mapper, na_action=None)Run the example
Edit the example and select Run Python to see the result.
Parameters
| Parameter | Requirement | Accepted values and behavior |
|---|---|---|
mapper |
Required Positional or keyword |
function, dict, or Series Provide a dictionary or callable that maps input values or labels. |
na_action |
Optional Positional or keyword Default None |
{None, 'ignore'} Control how the mapper treats missing inputs. |
Returns
pandas.Categorical or pandas.Index