[파이썬]캐글 타이타닉 데이터 탐색 #3(성별)


캐글 타이타닉 데이터 탐색 #3 (성별)

3번째 타이타닉 데이터 탐색을 해보려한다.

참고 : You Han Lee 유튜브

2.2 Sex (성별))

f, ax = plt.subplots(1, 2, figsize=(18,8))
df_train[['Sex', 'Survived']].groupby(['Sex'], as_index=True).mean().plot.bar(ax=ax[0])
ax[0].set_title('Survived vs Sex')
sns.countplot('Sex', hue='Survived', data=df_train, ax=ax[1])
ax[1].set_title('Sex: Survived vs Dead')
plt.show()

png

df_train[['Sex', 'Survived']].groupby(['Sex'], as_index=True).mean().plot.bar()
<matplotlib.axes._subplots.AxesSubplot at 0x7f50c6b77198>

png

df_train[['Sex', 'Survived']].groupby(['Sex'], as_index=False).mean()
SexSurvived
0female0.742038
1male0.188908
pd.crosstab(df_train['Sex'], df_train['Survived'], margins=True).style.background_gradient(cmap='summer_r')
Survived01All
Sex
female81233314
male468109577
All549342891

2.2 Both Sex and Pclass

sns.factorplot('Pclass', 'Survived', hue='Sex', data=df_train, size=6, aspect=1.5)
<seaborn.axisgrid.FacetGrid at 0x7f50c6b409e8>

png

  • Lady first.
  • Money brings survival?
sns.factorplot(x='Sex', y='Survived', hue='Pclass', data=df_train, saturation=5,
              size=9, aspect=1)
<seaborn.axisgrid.FacetGrid at 0x7f50c6ccd048>

png




© 2018. by statssy

Powered by statssy