application_vnd.jupyter.stderr_output_1.png
from sklearn.preprocessing import OrdinalEncoder

obj_cols = x_train.select_dtypes(include='object').columns
obj_cols

float_cols = x_train.select_dtypes(include='int64').columns
float_cols

from sklearn.preprocessing import OrdinalEncoder
oe = OrdinalEncoder(categories=[x_train[i].unique() for i in obj_cols])
oe.fit(x_train[obj_cols])
x_train_cat_encoded = oe.transform(x_train[obj_cols])
x_test_cat_encoded = oe.transform(x_test[obj_cols])

x_train_cat_encoded