我正在阅读 CSV,我想将其中一列设为分类,并按我自己的顺序排列。我怎么做?三个标签是“读”、“写”和“混合”。以下是一些不起作用的事情:
Categorical(my_csv.rw, ['read', 'write', 'mixed'])
ValueError: invalid literal for long() with base 10: 'mixed'
Categorical(my_csv.rw, Index(['read', 'write', 'mixed']))
ValueError: invalid literal for long() with base 10: 'mixed'
Categorical(['read', 'mixed', 'write'], Index(['read', 'write', 'mixed']))
ValueError: invalid literal for long() with base 10: 'mixed'
Categorical.from_array(['read', 'mixed', 'write']) # Levels in wrong order
那么,我该怎么做呢?