【发布时间】:2020-05-25 06:25:19
【问题描述】:
我只是在 Pandas 中弄湿脚趾,然后卡住了。我想按小时聚合 CSV 中的事件(获取计数),并在事件中有一个开始时间和结束时间。
即一个例子是:
event, start, end
soccer, 2020-01-20 00:34:00, 2020-01-20 02:34:00,
football, 2020-01-20 00:34:00, 2020-01-20 01:34:00
etc
预期输出:
00:00:00 - 2 (both began in 0th hour and went to 1st hour)
01:00:00 - 2 (both were live in 1st hour)
02:00:00 - 1 (only soccer occurred in 02 hour)
你会怎么做呢?我一直在尝试重新索引、重新采样、时差、时间索引——都没有运气。
【问题讨论】:
标签: python python-3.x pandas pandas-groupby