pandas.Series.cat.rename_categories

pandas 3.1.1 · Series and accessors · method

Change the labels of categories and preserve the underlying assignments.

Call syntax

Series.cat.rename_categories(new_categories)

Run the example

Edit the example and select Run Python to see the result.

Parameters

ParameterRequirementAccepted values and behavior
new_categories Required
Positional or keyword
list-like, dict-like or callable

Provide the category labels to add, assign, or reorder.

Returns

Categorical