The category codes of this categorical index.

Codes are an array of integers which are the positions of the actual values in the categories array.

There is no setter, use the other categorical methods and the normal item setter to change values in the categorical.


A non-writable view of the codes array.


For pandas.Categorical:

>>> cat = pd.Categorical(['a', 'b'], ordered=True)
array([0, 1], dtype=int8)

For pandas.CategoricalIndex:

>>> ci = pd.CategoricalIndex(['a', 'b', 'c', 'a', 'b', 'c'])
array([0, 1, 2, 0, 1, 2], dtype=int8)
>>> ci = pd.CategoricalIndex(['a', 'c'], categories=['c', 'b', 'a'])
array([2, 0], dtype=int8)