I’m reading a CSV, and I’d like to make one of the columns a Categorical, with my own ordering. How do I do that? The three labels are ‘read’, ‘write’ and ‘mixed’. Here are some things that don’t work:
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
So, how should I do it?
I believe the levels are ordered by the labels: