text_html_output_1.png
import numpy as np

import pandas as pd

train_df = pd.read_csv('../input/titanic/train.csv')
test_df = pd.read_csv('../input/titanic/test.csv')
train_labels = train_df['Survived']
train_df = train_df.drop(['Survived'], axis=1)
df = pd.concat([train_df, test_df])

def substrings_in_string(big_string, substrings):
    for substring in substrings:
        if str(big_string).find(substring) != -1:
            return substring
    return np.nan
title_list = ['Mrs', 'Mr', 'Master', 'Miss', 'Major', 'Rev', 'Dr', 'Ms', 'Mlle', 'Col', 'Capt', 'Mme', 'Countess', 'Don', 'Jonkheer']
df['Title'] = df['Name'].map(lambda x: substrings_in_string(x, title_list))
cabin_list = ['A', 'B', 'C', 'D', 'E', 'F', 'T', 'G', 'Unknown']
df['Deck'] = df['Cabin'].map(lambda x: substrings_in_string(x, cabin_list))
df['Alone'] = (df['SibSp'] + df['Parch'] == 0).astype('object')
numeric_columns = ['Age', 'SibSp', 'Parch', 'Fare']
categorical_columns = ['Pclass', 'Sex', 'Embarked', 'Title', 'Deck', 'Alone']
df['Pclass'] = df['Pclass'].astype('object')

df[numeric_columns].describe()