text_plain_output_1.png
from sklearn.preprocessing import OrdinalEncoder

import pandas as pd

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

import pandas as pd
test_data = pd.read_csv('../input/30-days-of-ml/test.csv', index_col=0)
train_data = pd.read_csv('../input/30-days-of-ml/train.csv', index_col=0)

train_data.isnull().sum()

train_drop_target = train_data.drop(['target'], axis=1)
y = train_data['target']
train_drop_target

cat_o = train_data.dtypes == 'object'
object_cols = list(cat_o[cat_o].index)
object_cols

X = train_drop_target.copy()
X_test = test_data.copy()
ordinal_encoder = OrdinalEncoder()
X[object_cols] = ordinal_encoder.fit_transform(train_drop_target[object_cols])
X_test[object_cols] = ordinal_encoder.transform(test_data[object_cols])

X_test