text_plain_output_2.png text_plain_output_1.png image_output_1.png
import matplotlib.pyplot as plt

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

import seaborn as sns

data = pd.read_csv('../input/titanic/train.csv')

data.isnull().sum()

data.groupby(['Sex', 'Survived'])['Survived'].count()

hm_data = data[['Survived', 'Pclass']]
hm_data = hm_data.groupby(['Pclass', 'Survived'])['Survived'].count()
hm_data = hm_data.unstack()

pd.crosstab([data.Sex, data.Survived], data.Pclass, margins=True).style.background_gradient(cmap='winter')

plt.figure(figsize=(10, 5))
sns.factorplot('Pclass', 'Survived', hue='Sex', data=data)
plt.title('Survived vs. Sex + Pclass')