pandas.CategoricalIndex.reorder_categories
pandas 3.1.1 · Index objects · method
Set the order of existing categories without changing which category each value belongs to.
Call syntax
CategoricalIndex.reorder_categories(new_categories, ordered=None)Run the example
Edit the example and select Run Python to see the result.
Parameters
| Parameter | Requirement | Accepted values and behavior |
|---|---|---|
new_categories |
Required Positional or keyword |
Index-like Provide the category labels to add, assign, or reorder. |
ordered |
Optional Positional or keyword Default None |
bool Choose whether the category sequence defines an ordering. |
Returns
CategoricalIndex