text_plain_output_1.png
from sklearn.preprocessing import OneHotEncoder, StandardScaler

import pandas as pd

train = pd.read_csv('../input/titanic/train.csv')
test = pd.read_csv('../input/titanic/test.csv')

df = pd.concat([train, test], axis=0).reset_index(drop=True)

df = df.drop(['PassengerId', 'Survived', 'Name', 'Ticket', 'Cabin'], axis=1)

df.isnull().sum().sort_values(ascending=False) * 100 / df.shape[0]

df.isnull().sum()

ohe = OneHotEncoder(sparse=False, handle_unknown='ignore')
transformed_f = ohe.fit_transform(df[['Sex', 'Embarked']])
transformed_f = pd.DataFrame(transformed_f, columns=['Sex0', 'Sex1', 'Embarked0', 'Embarked1', 'Embarked2'])

df = df.join(transformed_f)

df = df.drop(['Sex', 'Embarked'], axis=1)

df.head()