回答編集履歴
1
修正
test
CHANGED
@@ -2,7 +2,15 @@
|
|
2
2
|
|
3
3
|
参考:[Python: pandas の DataFrameGroupBy#agg() には関数も渡せる](https://blog.amedama.jp/entry/2018/04/16/230703)
|
4
4
|
|
5
|
+
|
6
|
+
|
7
|
+
単純な集計なら`.sum()`でよいです。
|
8
|
+
|
5
9
|
```Python
|
10
|
+
|
11
|
+
import pandas as pd
|
12
|
+
|
13
|
+
from io import StringIO
|
6
14
|
|
7
15
|
s = """A,B,C
|
8
16
|
|
@@ -31,6 +39,26 @@
|
|
31
39
|
#3 09031 20 30
|
32
40
|
|
33
41
|
#4 09031 30 40
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
dfg = df.groupby('A').sum()
|
48
|
+
|
49
|
+
print(dfg)
|
50
|
+
|
51
|
+
# B C
|
52
|
+
|
53
|
+
#A
|
54
|
+
|
55
|
+
#09011 20 10
|
56
|
+
|
57
|
+
#09021 80 30
|
58
|
+
|
59
|
+
#09031 50 70
|
60
|
+
|
61
|
+
|
34
62
|
|
35
63
|
|
36
64
|
|