I am converting strings to categorical values in my dataset using the following piece of code.
data[\'weekday\'] = pd.Categorical.from_array(data.weekday).labels
First, make a categorical series:
weekdays = pd.Series(['Sun', 'Sun', 'Wed', 'Mon', 'Mon']).astype('category')
Then, inspect its "categories":
weekdays.cat.categories.get_loc('Sun')