pandas.Series.cat.codes
- Series.cat.codes[source]
-
Return Series of codes as well as the index.
Examples
>>> raw_cate = pd.Categorical(["a", "b", "c", "a"], categories=["a", "b"]) >>> ser = pd.Series(raw_cate) >>> ser.cat.codes 0 0 1 1 2 -1 3 0 dtype: int8
© 2008–2011, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team
© 2011–2025, Open source contributors
Licensed under the 3-clause BSD License.
https://pandas.pydata.org/pandas-docs/version/2.3.0/reference/api/pandas.Series.cat.codes.html