回答編集履歴

1

追記

2019/01/11 07:14

投稿

can110
can110

スコア38266

test CHANGED
@@ -1 +1,39 @@
1
1
  pandasで読込までできたのであれば、あとは`data`と`side`で`groupby`して`volume`の`sum`をとればよいと思います。
2
+
3
+ 参考:[pandas.DataFrameをGroupByでグルーピングし統計量を算出](https://note.nkmk.me/python-pandas-groupby-statistics/)
4
+
5
+ ```Python
6
+
7
+ import pandas as pd
8
+
9
+ from io import StringIO
10
+
11
+
12
+
13
+ s = """2019-01-11 06:00:42 SELL 392684.0 0.080000
14
+
15
+ 2019-01-11 06:00:42 SELL 392685.0 0.080000
16
+
17
+ 2019-01-11 06:00:42 SELL 392685.0 0.020000
18
+
19
+ 2019-01-11 06:00:41 SELL 392684.0 0.010000
20
+
21
+ 2019-01-11 06:00:41 BUY 392694.0 0.047977
22
+
23
+ 2019-01-11 06:00:41 BUY 392691.0 0.051023
24
+
25
+ 2019-01-11 06:00:41 SELL 392684.0 0.010000
26
+
27
+ 2019-01-11 06:00:41 SELL 392684.0 0.100000
28
+
29
+ 2019-01-11 06:00:41 SELL 392684.0 0.090000
30
+
31
+ """
32
+
33
+ df = pd.read_csv(StringIO(s),header=None,delim_whitespace=True,names=['date','side','price','volume'])
34
+
35
+ grouped = df.groupby(['date','side'])
36
+
37
+ print(grouped.sum()['volume'])
38
+
39
+ ```