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
train['cat'] = train['cat'].map(list(train['cat'].value_counts().to_frame().reset_index().reset_index().set_index('index').to_dict().values())[0])