我有一个df(样本最后粘贴在这里)。
我希望找到每分钟tradePrice
tradeVolume
最多的 minute
tradePrice Data 0 1 10 Total Result
12548 Sum - tradeVolume 3 3
Count - tradePrice 2 2
12548.5 Sum - tradeVolume 1 1
Count - tradePrice 1 1
12549 Sum - tradeVolume 1 1
Count - tradePrice 1 1
12549.5 Sum - tradeVolume 95 95
Count - tradePrice 5 5
12550 Sum - tradeVolume 6 6
Count - tradePrice 4 4
12559 Sum - tradeVolume 93 93
Count - tradePrice 1 1
12559.5 Sum - tradeVolume 1 1
Count - tradePrice 1 1
12560 Sum - tradeVolume 5 5
Count - tradePrice 4 4
12560.5 Sum - tradeVolume 3 5 8
Count - tradePrice 3 2 5
12561 Sum - tradeVolume 4 5 9
Count - tradePrice 2 3 5
12561.5 Sum - tradeVolume 3 2 5
Count - tradePrice 3 1 4
12562 Sum - tradeVolume 9 7 16
Count - tradePrice 8 1 9
12562.5 Sum - tradeVolume 6 2 8
Count - tradePrice 2 2 4
12563 Sum - tradeVolume 2 2
Count - tradePrice 1 1
Total Sum - tradeVolume 120 27 106 253
Total Count - tradePrice 20 14 13 47
。这是一个发送到新df的数据透视表。
xls中的数据透视表如下所示:
Price Volume
02:00:00 AM 12559 93
02:01:00 AM 12562 7
02:10:00 AM 12549.5 95
结果需要像这样搜索交易量最大的价格:
Price Volume
02:10:00 AM 12549.5 95
我的问题是: 1.我如何将这个转轴变成1分钟df? 2.如何获得相同的结果,但每个滚动时间段(不能少于1分钟),所以最后10分钟的预期结果(以最大交易量交易的价格)是:
dateTime tradePrice tradeVolume 1min time_of_day_10 time_of_day_30 date hour minute
0 2017-09-19 02:00:04 12559 93 2017-09-19 02:00:00 02:00:00 02:00:00 2017-09-19 2 0
49 2017-09-19 02:00:11 12562 1 2017-09-19 02:00:00 02:00:00 02:00:00 2017-09-19 2 0
50 2017-09-19 02:00:12 12563 2 2017-09-19 02:00:00 02:00:00 02:00:00 2017-09-19 2 0
51 2017-09-19 02:00:12 12562 1 2017-09-19 02:00:00 02:00:00 02:00:00 2017-09-19 2 0
122 2017-09-19 02:00:34 12561.5 1 2017-09-19 02:00:00 02:00:00 02:00:00 2017-09-19 2 0
123 2017-09-19 02:00:34 12562 1 2017-09-19 02:00:00 02:00:00 02:00:00 2017-09-19 2 0
127 2017-09-19 02:00:34 12562 1 2017-09-19 02:00:00 02:00:00 02:00:00 2017-09-19 2 0
129 2017-09-19 02:00:35 12561 2 2017-09-19 02:00:00 02:00:00 02:00:00 2017-09-19 2 0
130 2017-09-19 02:00:35 12560.5 1 2017-09-19 02:00:00 02:00:00 02:00:00 2017-09-19 2 0
131 2017-09-19 02:00:35 12561.5 1 2017-09-19 02:00:00 02:00:00 02:00:00 2017-09-19 2 0
135 2017-09-19 02:00:39 12562 1 2017-09-19 02:00:00 02:00:00 02:00:00 2017-09-19 2 0
136 2017-09-19 02:00:39 12562 1 2017-09-19 02:00:00 02:00:00 02:00:00 2017-09-19 2 0
137 2017-09-19 02:00:43 12561.5 1 2017-09-19 02:00:00 02:00:00 02:00:00 2017-09-19 2 0
138 2017-09-19 02:00:43 12561 2 2017-09-19 02:00:00 02:00:00 02:00:00 2017-09-19 2 0
139 2017-09-19 02:00:43 12560.5 1 2017-09-19 02:00:00 02:00:00 02:00:00 2017-09-19 2 0
140 2017-09-19 02:00:43 12560.5 1 2017-09-19 02:00:00 02:00:00 02:00:00 2017-09-19 2 0
152 2017-09-19 02:00:45 12562 2 2017-09-19 02:00:00 02:00:00 02:00:00 2017-09-19 2 0
153 2017-09-19 02:00:46 12562.5 4 2017-09-19 02:00:00 02:00:00 02:00:00 2017-09-19 2 0
166 2017-09-19 02:00:58 12562 1 2017-09-19 02:00:00 02:00:00 02:00:00 2017-09-19 2 0
167 2017-09-19 02:00:58 12562.5 2 2017-09-19 02:00:00 02:00:00 02:00:00 2017-09-19 2 0
168 2017-09-19 02:01:00 12562 7 2017-09-19 02:01:00 02:00:00 02:00:00 2017-09-19 2 1
169 2017-09-19 02:01:00 12562.5 1 2017-09-19 02:01:00 02:00:00 02:00:00 2017-09-19 2 1
170 2017-09-19 02:01:00 12562.5 1 2017-09-19 02:01:00 02:00:00 02:00:00 2017-09-19 2 1
171 2017-09-19 02:01:00 12561.5 2 2017-09-19 02:01:00 02:00:00 02:00:00 2017-09-19 2 1
175 2017-09-19 02:01:03 12561 1 2017-09-19 02:01:00 02:00:00 02:00:00 2017-09-19 2 1
176 2017-09-19 02:01:03 12561 3 2017-09-19 02:01:00 02:00:00 02:00:00 2017-09-19 2 1
187 2017-09-19 02:01:07 12560.5 2 2017-09-19 02:01:00 02:00:00 02:00:00 2017-09-19 2 1
188 2017-09-19 02:01:08 12561 1 2017-09-19 02:01:00 02:00:00 02:00:00 2017-09-19 2 1
189 2017-09-19 02:01:10 12560 1 2017-09-19 02:01:00 02:00:00 02:00:00 2017-09-19 2 1
190 2017-09-19 02:01:10 12560 1 2017-09-19 02:01:00 02:00:00 02:00:00 2017-09-19 2 1
191 2017-09-19 02:01:10 12559.5 1 2017-09-19 02:01:00 02:00:00 02:00:00 2017-09-19 2 1
192 2017-09-19 02:01:11 12560 1 2017-09-19 02:01:00 02:00:00 02:00:00 2017-09-19 2 1
193 2017-09-19 02:01:12 12560 2 2017-09-19 02:01:00 02:00:00 02:00:00 2017-09-19 2 1
194 2017-09-19 02:01:12 12560.5 3 2017-09-19 02:01:00 02:00:00 02:00:00 2017-09-19 2 1
593 2017-09-19 02:10:00 12550 1 2017-09-19 02:10:00 02:10:00 02:00:00 2017-09-19 2 10
594 2017-09-19 02:10:00 12549.5 12 2017-09-19 02:10:00 02:10:00 02:00:00 2017-09-19 2 10
604 2017-09-19 02:10:12 12548.5 1 2017-09-19 02:10:00 02:10:00 02:00:00 2017-09-19 2 10
605 2017-09-19 02:10:15 12549.5 22 2017-09-19 02:10:00 02:10:00 02:00:00 2017-09-19 2 10
606 2017-09-19 02:10:16 12549.5 21 2017-09-19 02:10:00 02:10:00 02:00:00 2017-09-19 2 10
636 2017-09-19 02:10:45 12548 1 2017-09-19 02:10:00 02:10:00 02:00:00 2017-09-19 2 10
637 2017-09-19 02:10:47 12548 2 2017-09-19 02:10:00 02:10:00 02:00:00 2017-09-19 2 10
638 2017-09-19 02:10:47 12549.5 23 2017-09-19 02:10:00 02:10:00 02:00:00 2017-09-19 2 10
639 2017-09-19 02:10:48 12549.5 17 2017-09-19 02:10:00 02:10:00 02:00:00 2017-09-19 2 10
640 2017-09-19 02:10:49 12549 1 2017-09-19 02:10:00 02:10:00 02:00:00 2017-09-19 2 10
665 2017-09-19 02:10:58 12550 1 2017-09-19 02:10:00 02:10:00 02:00:00 2017-09-19 2 10
666 2017-09-19 02:10:58 12550 1 2017-09-19 02:10:00 02:10:00 02:00:00 2017-09-19 2 10
667 2017-09-19 02:10:58 12550 3 2017-09-19 02:10:00 02:10:00 02:00:00 2017-09-19 2 10
样本数据:
UserChecker