回答編集履歴

1

Update

2021/12/13 15:29

投稿

melian
melian

スコア20655

test CHANGED
@@ -16,7 +16,9 @@
16
16
 
17
17
  # pivot
18
18
 
19
- dfy = df.pivot_table(index='name', columns='subject', values='score')
19
+ dfy = df.pivot_table(index='name', columns='subject', values='score', sort=False)
20
+
21
+ dfy = dfy[['math','english','physics']] # columns order
20
22
 
21
23
  print(dfy)
22
24
 
@@ -34,14 +36,14 @@
34
36
 
35
37
 
36
38
 
37
- subject english math physics
39
+ subject math english physics
38
40
 
39
41
  name
40
42
 
41
- Jiro 97 92 90
43
+ Taro 86 92 80
42
44
 
43
- Ken 70 100 92
45
+ Jiro 92 97 90
44
46
 
45
- Taro 92 86 80
47
+ Ken 100 70 92
46
48
 
47
49
  ```