text_html_output_1.png
from sklearn.preprocessing import LabelEncoder

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

train = pd.read_csv('../input/30-days-of-ml/train.csv')
test = pd.read_csv('../input/30-days-of-ml/test.csv')

categorical = [col for col in train.columns if train[col].dtype == 'object']
encoder = LabelEncoder()
for column in categorical:
    train[column] = encoder.fit_transform(train[column])
    test[column] = encoder.transform(test[column])

X = train.drop(['id', 'target'], axis=1)
y = train['target']
X_valid = test.drop(['id'], axis=1)
X.head()