pandas.Series.cat.codes

Series.cat.codes

Return Series of codes as well as the index.