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

import random

features = ['Pclass_1', 'Pclass_2', 'Pclass_3', 'Sex_female', 'Age', 'SibSp', 'Parch', 'Fare']
df = pd.read_csv('../input/train.csv')
t = pd.DataFrame({'Validation': list(map(lambda x: random.random() < 0.3, range(891)))})
x_preprocess = pd.DataFrame({'Pclass_1': (df['Pclass'] == 1) * 1, 'Pclass_2': (df['Pclass'] == 2) * 1, 'Pclass_3': (df['Pclass'] == 3) * 1, 'Sex_female': (df['Sex'] == 'female') * 1, 'Age': df['Age'] / pd.Series.std(df['Age']), 'SibSp': df['SibSp'], 'Parch': df['Parch'], 'Fare': df['Fare'] / pd.Series.std(df['Fare'])})
x_preprocess.fillna(0, inplace=True)
y = pd.DataFrame({'Survived': df['Survived']})
y_train = y[t['Validation'] == False]
x_train = x_preprocess[t['Validation'] == False]
y_validation = y[t['Validation']]
x_validation = x_preprocess[t['Validation']]
print(y_train[['Survived']].values)