pandas.CategoricalIndex.reorder_categories#
- CategoricalIndex.reorder_categories(*args, **kwargs)[source]#
Reorder categories as specified in new_categories.
new_categories need to include all old categories and no new category items.
- Parameters
- new_categoriesIndex-like
The categories in new order.
- orderedbool, optional
Whether or not the categorical is treated as a ordered categorical. If not given, do not change the ordered information.
- Returns
- Categorical
Categorical with reordered categories.
- Raises
- ValueError
If the new categories do not contain all old category items or any new ones
See also
rename_categoriesRename categories.
add_categoriesAdd new categories.
remove_categoriesRemove the specified categories.
remove_unused_categoriesRemove categories which are not used.
set_categoriesSet the categories to the specified ones.