text_plain_output_1.png
import pandas as pd

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

train.isnull().sum()

test.isnull().sum()

train['Age'] = train['Age'].fillna(train['Age'].median())
test['Age'] = test['Age'].fillna(test['Age'].median())
train.drop('Cabin', axis=1, inplace=True)
test.drop('Cabin', axis=1, inplace=True)
train['Embarked'] = train['Embarked'].fillna('S')
test['Fare'] = test['Fare'].fillna(test['Fare'].median())

train.drop('Name', axis=1, inplace=True)
test.drop('Name', axis=1, inplace=True)
train.drop('Ticket', axis=1, inplace=True)
test.drop('Ticket', axis=1, inplace=True)
train = train.join(pd.get_dummies(train['Sex'], prefix='sex'))
test = test.join(pd.get_dummies(test['Sex'], prefix='sex'))
train = train.join(pd.get_dummies(train['Embarked'], prefix='emberk'))
test = test.join(pd.get_dummies(test['Embarked'], prefix='emberk'))

train.drop(['Sex', 'Embarked'], axis=1, inplace=True)
test.drop(['Sex', 'Embarked'], axis=1, inplace=True)

X_train = train.drop('Survived', axis=1)
y_train = train['Survived'].values

X_train.head()