pandas 时间戳的累积时间总和
我试图从给定事件跟踪中的时间戳中查找时间总和(以秒为单位)。数据输入和输出位于 Pandas DataFrame 中。怎么可能做到这一点呢?
输入示例:
CaseID Timestamps
0 2016-01-01 09:51:15.304000+00:00
0 2016-01-01 09:53:15.352000+00:00
1 2016-01-01 09:51:15.774000+00:00
1 2016-01-01 09:51:47.392000+00:00
1 2016-01-01 09:52:15.403000+00:00
我希望总和也能累加;忽略诸如毫秒之类的微小差异。
示例输出:
Case ID sum_time
0 0
0 120
1 0
1 32
1 60
I am trying to find the sum of time (in seconds) from timestamps in a given trace of events. The data input and output is in a Pandas DataFrame. How would it be possible to do that?
Example Input :
CaseID Timestamps
0 2016-01-01 09:51:15.304000+00:00
0 2016-01-01 09:53:15.352000+00:00
1 2016-01-01 09:51:15.774000+00:00
1 2016-01-01 09:51:47.392000+00:00
1 2016-01-01 09:52:15.403000+00:00
I would like for the sum to be added cumulatively as well; disregarding minuscule differences such as the milliseconds.
Example Output:
Case ID sum_time
0 0
0 120
1 0
1 32
1 60
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这应该可以解决问题,
结果:
This should should solve the problem,
Result: