回答編集履歴

1

Update

2022/06/22 02:21

投稿

melian
melian

スコア19825

test CHANGED
@@ -1,19 +1,18 @@
1
1
  ```python
2
- df_per = df.groupby('Type').apply(lambda x:
2
+ df_per = df.groupby('Type')\
3
- pd.Series([len(x.query('-30 <= Score1 < 30'))/len(x),
3
+ .apply(lambda x: len(x.query('-30 <= Score1 < 30 and 55 <= Score2 < 100'))/len(x))\
4
- len(x.query('55 <= Score2 < 100'))/len(x)],
4
+ .to_frame('ratio')
5
- index=['-30 <= Score1 < 30', '55 <= Score2 < 100']))
6
5
 
7
6
  print(df_per)
8
7
 
9
8
  #
10
- -30 <= Score1 < 30 55 <= Score2 < 100
9
+ ratio
11
- Type
10
+ Type
12
- CB 0.56 0.30
11
+ CB 0.18
13
- CU 0.65 0.34
12
+ CU 0.14
14
- FF 0.60 0.25
13
+ FF 0.20
15
- SI 0.57 0.25
14
+ SI 0.19
16
- SL 0.58 0.31
15
+ SL 0.20
17
- SP 0.59 0.28
16
+ SP 0.18
18
17
  ```
19
18