text_plain_output_2.png application_vnd.jupyter.stderr_output_1.png image_output_1.png
import matplotlib.pyplot as plt

import pandas as pd

import seaborn as sns

import pandas as pd
import numpy as np
train = pd.read_csv('../input/titanic/train.csv')
test = pd.read_csv('../input/titanic/test.csv')
gender_submission_df = pd.read_csv('../input/titanic/gender_submission.csv')

Parch_and_SibSp_col = train.Parch.astype(str) + ':' + train.SibSp.astype(str)
train.assign(Parch_SibSp=Parch_and_SibSp_col)[['Parch_SibSp', 'Survived']].groupby(['Parch_SibSp'], as_index=False).mean().sort_values(by='Survived', ascending=False)

Parch_and_SibSp_col = train.Parch.astype(str) + ':' + train.SibSp.astype(str)
train.assign(Parch_SibSp=Parch_and_SibSp_col)[['Parch_SibSp', 'Survived', 'Pclass', 'Age']].groupby(['Parch_SibSp'], as_index=False).median().sort_values(by='Survived', ascending=False)

train.assign(Sex_Pclass=train.Sex.astype(str) + ':' + train.Pclass.astype(str))[['Sex_Pclass', 'Survived', 'Pclass', 'Age']].groupby(['Sex_Pclass'], as_index=False).mean(numeric_only=True).sort_values(by='Survived', ascending=False)

train.assign(Embarked_Sex_Pclass=train.Embarked + ':' + train.Sex + ':' + train.Pclass.astype(str))[['Embarked_Sex_Pclass', 'Survived', 'Age']].groupby(['Embarked_Sex_Pclass'], as_index=False).mean(numeric_only=True).sort_values(by='Survived', ascending=False)

import seaborn as sns
import matplotlib.pyplot as plt
g = sns.FacetGrid(train, col='Survived')
g.map(plt.hist, 'Age', bins=20)

grid = sns.FacetGrid(train, col='Survived', row='Pclass', aspect=1.6)
grid.map(plt.hist, 'Age', alpha=0.5, bins=20)
grid.add_legend()