how to change categorical data to numerical data pyrthon code example
Example 1: how to convert contionous data into categorical data in python
pd.cut(df.Age,bins=[0,2,17,65,99],labels=['Toddler/Baby','Child','Adult','Elderly'])
# where bins is cut off points of bins for the continuous data
# and key things here is that no. of labels is always less than 1
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