如何计算在Python中按ID和时间戳(按月)分组的平均值

时间:2017-03-07 16:33:44

标签: python

我有以下数据集,并尝试生成按ID和月分组的以下输出。每条记录的持续时间(分钟)基本上是ID处于当前状态的总分钟数:

ID,时间ID计数状态为“不可用”,月份,年份,状态“不可用”的平均次数,状态“不可用”的平均持续时间

Digital Id Reference,Timestamp,Status,Duration in Minutes
99,1/1/2017 0:05,Available,622
99,1/1/2017 10:27,Unavailable,15
99,1/1/2017 10:42,Available,75
99,1/1/2017 11:57,Unavailable,15
99,1/1/2017 12:12,Available,615
99,1/1/2017 22:27,Unavailable,25
99,1/1/2017 22:52,Available,850
99,1/2/2017 13:02,Unavailable,15
99,1/2/2017 13:17,Available,450
99,1/2/2017 20:47,Unavailable,683
99,1/3/2017 8:10,Available,500
99,1/3/2017 16:30,Unavailable,54
99,1/3/2017 17:24,Available,13
99,1/3/2017 17:37,Unavailable,31
99,1/3/2017 18:08,Available,839
99,1/4/2017 8:07,Unavailable,15
99,1/4/2017 8:22,Available,90
99,1/4/2017 9:52,Unavailable,26
99,1/4/2017 10:18,Available,126
99,1/4/2017 12:24,Unavailable,24
99,1/4/2017 12:48,Available,64
99,1/4/2017 13:52,Unavailable,61
99,1/4/2017 14:53,Available,92
99,1/4/2017 16:25,Unavailable,53
99,1/4/2017 17:18,Available,9
99,1/4/2017 17:27,Unavailable,31
99,1/4/2017 17:58,Available,44
99,1/4/2017 18:42,Unavailable,46
99,1/4/2017 19:28,Available,14
99,1/4/2017 19:42,Unavailable,30
99,1/4/2017 20:12,Available,1215
99,1/5/2017 16:27,Unavailable,15
99,1/5/2017 16:42,Available,30
99,1/5/2017 17:12,Unavailable,46
99,1/5/2017 17:58,Available,99
99,1/5/2017 19:37,Unavailable,10
99,1/5/2017 19:47,Available,675
99,1/6/2017 7:02,Unavailable,15
99,1/6/2017 7:17,Available,75
99,1/6/2017 8:32,Unavailable,31
99,1/6/2017 9:03,Available,134
99,1/6/2017 11:17,Unavailable,15
99,1/6/2017 11:32,Available,105
99,1/6/2017 13:17,Unavailable,15
99,1/6/2017 13:32,Available,30
99,1/6/2017 14:02,Unavailable,15
99,1/6/2017 14:17,Available,140
99,1/6/2017 16:37,Unavailable,10
99,1/6/2017 16:47,Available,105
99,1/6/2017 18:32,Unavailable,28
99,1/6/2017 19:00,Available,17
99,1/6/2017 19:17,Unavailable,15
99,1/6/2017 19:32,Available,60
99,1/6/2017 20:32,Unavailable,15
99,1/6/2017 20:47,Available,62
99,1/6/2017 21:49,Unavailable,31
99,1/6/2017 22:20,Available,557
99,1/7/2017 7:37,Unavailable,15
99,1/7/2017 7:52,Available,90
99,1/7/2017 9:22,Unavailable,15
99,1/7/2017 9:37,Available,75
99,1/7/2017 10:52,Unavailable,15
99,1/7/2017 11:07,Available,195
99,1/7/2017 14:22,Unavailable,16
99,1/7/2017 14:38,Available,89
99,1/7/2017 16:07,Unavailable,15
99,1/7/2017 16:22,Available,30
99,1/7/2017 16:52,Unavailable,30
99,1/7/2017 17:22,Available,360
99,1/7/2017 23:22,Unavailable,15
123,1/1/2017 0:04,Available,1573
123,1/2/2017 2:17,Unavailable,411
123,1/2/2017 9:08,Available,3379
123,1/4/2017 17:27,Unavailable,15
123,1/4/2017 17:42,Available,150
123,1/4/2017 20:12,Unavailable,15
123,1/4/2017 20:27,Available,3865
123,1/7/2017 12:52,Unavailable,15
126,1/2/2017 18:25,Available,1096
126,1/3/2017 12:41,Unavailable,15
126,1/3/2017 12:56,Available,150
126,1/3/2017 15:26,Unavailable,31
126,1/3/2017 15:57,Available,2133
126,1/5/2017 3:30,Unavailable,329
126,1/5/2017 8:59,Available,147
126,1/5/2017 11:26,Unavailable,31
126,1/5/2017 11:57,Available,1199
126,1/6/2017 7:56,Unavailable,15
126,1/6/2017 8:11,Available,840
126,1/6/2017 22:11,Unavailable,15
134,1/1/2017 0:03,Available,1323
134,1/1/2017 22:06,Unavailable,801
134,1/2/2017 11:27,Available,4249
134,1/5/2017 10:16,Unavailable,7
134,1/5/2017 10:23,Available,2676
134,1/7/2017 6:59,Unavailable,9
151,1/1/2017 0:09,Available,3614
151,1/3/2017 12:23,Unavailable,87
151,1/3/2017 13:50,Available,6283

0 个答案:

没有答案