pandas.CategoricalIndex.add_categories

pandas 3.1.1 · Index objects · method

Extend the list of permitted categories without changing observations.

Call syntax

CategoricalIndex.add_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
category or list-like of category

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

Returns

CategoricalIndex