text_plain_output_1.png
import numpy as np # linear algebra

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

train_data = pd.read_csv('../input/train.csv')
test_data = pd.read_csv('../input/test.csv')
files_listing = test_data.PassengerId
test_labels = pd.read_csv('../input/gender_submission.csv')

labels_test = test_labels.values
labels_test = labels_test[:, 1]
test_data = test_data.drop(['Name', 'SibSp', 'Parch', 'Ticket', 'Fare', 'Cabin', 'Embarked'], axis=1)
test_data.Age = test_data.Age.fillna(np.mean(train_data.Age))
test_data.Sex = test_data.Sex.apply(lambda x: 1 if x == 'male' else 0)
test_data = test_data.values
test_data = test_data[:, 1:]
features_test = test_data

train_data = train_data.drop(['Name', 'SibSp', 'Parch', 'Ticket', 'Fare', 'Cabin', 'Embarked'], axis=1)

train_data['Age'] = train_data['Age'].fillna(np.mean(train_data.Age))
train_data['Sex'] = train_data['Sex'].apply(lambda x: 1 if x == 'male' else 0)
train_data.head()