答案 0 :(得分:0)
您可以使用此:
df['column'] = df['column'].astype('category').cat.codes
示例:
df = pd.DataFrame(['a','b','c','d','a','c','a','d'], columns=['column'])
输出:
column
0 0
1 1
2 2
3 3
4 0
5 2
6 0
7 3