image_output_4.png image_output_3.png image_output_2.png image_output_1.png
import matplotlib.pyplot as plt

import numpy as np # linear algebra

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

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

gender_pivot = train.pivot_table(index='Sex', values='Survived')
gender_pivot.plot.bar()
plt.show()
class_pivot = train.pivot_table(index='Pclass', values='Survived')
class_pivot.plot.bar()
plt.show()
family_cols = ['SibSp', 'Parch', 'Survived']
family = train[family_cols].copy()
family['familysize'] = family[['SibSp', 'Parch']].sum(axis=1)
familySize = family[['SibSp', 'Parch']].sum(axis=1)
family['isalone'] = np.where(familySize >= 1, 1, 0)
family_pivot = family.pivot_table(index='familysize', values='Survived')
isalone_pivot = family.pivot_table(index='isalone', values='Survived')
isalone_pivot.plot.bar(ylim=(0, 1), yticks=np.arange(0, 1, 0.1))
family_pivot.plot.bar(ylim=(0, 1), yticks=np.arange(0, 1, 0.1))
plt.show()