text_html_output_1.png
from sklearn.preprocessing import OrdinalEncoder

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

train = pd.read_csv('../input/kk30ml/train.csv', index_col=0)
test = pd.read_csv('../input/kk30ml/test.csv', index_col=0)
train

y = train['target']
X = train.drop(['target'], axis=1)

from sklearn.preprocessing import OrdinalEncoder
cat = X.dtypes == 'object'
cat_l = list(cat[cat].index)
X_Tr = X.copy()
X_test = test.copy()
ordinal_encoder = OrdinalEncoder()
X_Tr[cat_l] = ordinal_encoder.fit_transform(X[cat_l])
X_test[cat_l] = ordinal_encoder.transform(X_test[cat_l])
X_Tr.head()