回答編集履歴

1

コメントに対応して修正

2021/06/22 13:56

投稿

ppaul
ppaul

スコア24666

test CHANGED
@@ -1,4 +1,6 @@
1
- たしかこうです。確認はしていません。
1
+ ~~たしかこうです。確認はしていません。~~
2
+
3
+ 修正しました。
2
4
 
3
5
 
4
6
 
@@ -6,15 +8,15 @@
6
8
 
7
9
  f, ax = plt.subplots(1, 3, figsize = (18, 8))
8
10
 
9
- train_data[['Sex', 'Survived']].groupby(['Sex']).mean().plot.bar(ax = ax[0][0])
11
+ train_data[['Sex', 'Survived']].groupby(['Sex']).mean().plot.bar(ax = ax[0])
10
12
 
11
- ax[0][0].set_title('Sex vs Survived')
13
+ ax[0].set_title('Sex vs Survived')
12
14
 
13
- sns.countplot('Sex', hue = 'Survived', data = train_data, ax = ax[0][1])
15
+ sns.countplot('Sex', hue = 'Survived', data = train_data, ax = ax[1])
14
16
 
15
- ax[0][1].set_title('Sex → survived or not')
17
+ ax[1].set_title('Sex → survived or not')
16
18
 
17
- train_data.groupby('Sex')['Survived'].value_counts(normalize=True).mul(100).rename('percent').reset_index().pipe((sns.catplot,'data'), x='Sex',y='percent',hue='Survived',kind='bar', ax = ax[0][2])
19
+ train_data.groupby('Sex')['Survived'].value_counts(normalize=True).mul(100).rename('percent').reset_index().pipe((sns.catplot,'data'), x='Sex',y='percent',hue='Survived',kind='bar', ax = ax[2])
18
20
 
19
21
  plt.show()
20
22