1from sklearn.preprocessing import LabelEncoder
2
3le = LabelEncoder()
4companydata.ShelveLoc = le.fit_transform(companydata.ShelveLoc)
1
2obj_df["body_style"] = obj_df["body_style"].astype('category')
3obj_df.dtypes
4
5obj_df["body_style_cat"] = obj_df["body_style"].cat.codes
6obj_df.head()
7
1from sklearn.preprocessing import LabelEncoder
2
3lb_make = LabelEncoder()
4obj_df["make_code"] = lb_make.fit_transform(obj_df["make"])
5obj_df[["make", "make_code"]].head(11)
6