【问题标题】:I am working on a time-series data. How do I sum time of a particular day?我正在处理时间序列数据。我如何总结某一天的时间?
【发布时间】:2019-10-19 15:03:37
【问题描述】:

enter image description hereenter image description here

图像包含一个以机器 ID 和时间实例为列的数据集,我必须计算机器每天工作的总时间。

【问题讨论】:

  • 请将示例数据复制粘贴到您的问题中

标签: dataframe time-series data-science


【解决方案1】:

试试这样的..

t1 = pd.to_datetime('1/1/2015 01:00')

t2 = pd.to_datetime('1/1/2015 03:30')

#in seconds
print pd.Timedelta(t2 - t1).seconds / 3600.0

#in hours
print pd.Timedelta(t2 - t1).seconds / 60.0

【讨论】:

  • 但是我必须计算很多天的时间。我该怎么做???
  • 机器ID时间实例0 5018 2019-01-16 04:47:43.836 1 5018 2019-01-16 04:47:43.835 2 5018 2019-01-16 04:47:42.836 3 5018 2019- 01-16 04:47:42.833 4 5018 2019-01-16 04:47:41.832 5 5018 2019-01-16 04:47:41.831 6 5018 2019-01-16 04:47:39.848 7 5018 2019-1 16 04:47:39.843 8 5018 2019-01-16 04:47:38.835 9 5018 2019-01-16 04:47:37.848 10 5018 2019-01-16 04:47:37.835 11 5018 2019-01 :47:36.847 12 5018 2019-01-16 04:47:36.846 13 5018 2019-01-16 04:47:34.838 14 5018 2019-01-16 04:47:34.837
猜你喜欢
  • 2021-02-26
  • 2017-10-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-11-04
  • 1970-01-01
  • 2015-12-12
相关资源
最近更新 更多