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

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

all_data = pd.concat((train.loc[:, 'Pclass':'Embarked'], test.loc[:, 'Pclass':'Embarked']))

all_data.Age = all_data.Age.fillna(all_data.Age.median())
all_data.Fare = all_data.Fare.fillna(all_data.Fare.median())
all_data.Embarked = all_data.Embarked.fillna(all_data.Embarked.mode()[0])

all_data['Title'] = all_data['Name'].str.split(', ', expand=True)[1].str.split('.', expand=True)[0]
stat_min = 10
title_names = all_data['Title'].value_counts() < stat_min
all_data['Title'] = all_data['Title'].apply(lambda x: 'Misc' if title_names.loc[x] == True else x)
print(all_data['Title'].value_counts())
all_data = all_data.drop(['Name'], axis=1)
all_data = all_data.drop(['Ticket'], axis=1)
all_data = all_data.drop(['Cabin'], axis=1)
all_data.info()