numeric to categorical pandas code example
Example 1: pandas categorical to numeric
#this will label the different catagories as 0,1,2,3....
dataset["sex"] = dataset["sex"].astype('category').cat.codes
Example 2: how to convert categorical data to numerical data in python
obj_df["body_style"] = obj_df["body_style"].astype('category')
obj_df.dtypes