pandas.CategoricalIndex.categories#

property CategoricalIndex.categories[source]#

The categories of this CategoricalIndex.

These are the unique values the index may hold, in category order. Use the *_categories methods to return an index with changed categories.

See also

CategoricalIndex.rename_categories

Rename categories.

CategoricalIndex.reorder_categories

Reorder categories.

CategoricalIndex.add_categories

Add new categories.

CategoricalIndex.remove_categories

Remove the specified categories.

CategoricalIndex.remove_unused_categories

Remove categories which are not used.

CategoricalIndex.set_categories

Set the categories to the specified ones.

Examples

>>> ci = pd.CategoricalIndex(["a", "c", "b", "a", "c", "b"])
>>> ci.categories
Index(['a', 'b', 'c'], dtype='str')
>>> ci = pd.CategoricalIndex(["a", "c"], categories=["c", "b", "a"])
>>> ci.categories
Index(['c', 'b', 'a'], dtype='str')