pyspark.pandas.CategoricalIndex.codes¶
-
property
CategoricalIndex.
codes
¶ The category codes of this categorical.
Codes are an Index of integers which are the positions of the actual values in the categories Index.
There is no setter, use the other categorical methods and the normal item setter to change values in the categorical.
- Returns
- Index
A non-writable view of the codes Index.
Examples
>>> idx = ps.CategoricalIndex(list("abbccc")) >>> idx CategoricalIndex(['a', 'b', 'b', 'c', 'c', 'c'], categories=['a', 'b', 'c'], ordered=False, dtype='category')
>>> idx.codes Int64Index([0, 1, 1, 2, 2, 2], dtype='int64')