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
*_categoriesmethods to return an index with changed categories.See also
CategoricalIndex.rename_categoriesRename categories.
CategoricalIndex.reorder_categoriesReorder categories.
CategoricalIndex.add_categoriesAdd new categories.
CategoricalIndex.remove_categoriesRemove the specified categories.
CategoricalIndex.remove_unused_categoriesRemove categories which are not used.
CategoricalIndex.set_categoriesSet 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')