0

I have a dataframe as follows, where the elapsed_sum is simply the cumulative sum of stopped_at - started_at in seconds.

{'started_at': {1418: Timestamp('2019-03-29 08:06:16.645000'),
  1417: Timestamp('2019-03-29 11:57:34.192000'),
  1423: Timestamp('2019-03-31 19:17:02.444000'),
  1422: Timestamp('2019-04-01 04:35:57.777000'),
  1421: Timestamp('2019-04-01 06:19:33.602000'),
  1420: Timestamp('2019-04-01 09:35:02.339000'),
  1425: Timestamp('2019-04-03 03:58:38.005000'),
  1424: Timestamp('2019-04-03 04:57:39.924000'),
  1419: Timestamp('2019-04-04 10:34:09.262000')},
 'stopped_at': {1418: Timestamp('2019-03-29 08:06:21.611000'),
  1417: Timestamp('2019-03-29 13:32:15.022000'),
  1423: Timestamp('2019-03-31 20:34:32.785000'),
  1422: Timestamp('2019-04-01 05:32:48.564000'),
  1421: Timestamp('2019-04-01 09:03:21.748000'),
  1420: Timestamp('2019-04-01 10:29:52.943000'),
  1425: Timestamp('2019-04-03 04:57:39.849000'),
  1424: Timestamp('2019-04-03 05:11:59.854000'),
  1419: Timestamp('2019-04-04 12:16:58.755000')},
 'elapsed_sum': {1418: 4.0,
  1417: 5684.0,
  1423: 10334.0,
  1422: 13744.0,
  1421: 23572.0,
  1420: 26862.0,
  1425: 30403.0,
  1424: 31262.0,
  1419: 37431.0}}

enter image description here I would like to convert this into a regular time series where the x-axis is defined as follows:

start = df.started_at.min()
stop = df.stopped_at.max()
timetaken = stop-start

x = pd.timedelta_range(0, timetaken, freq = 'H')
Mehtab Pathan
  • 443
  • 4
  • 15
  • 1
    Had you used a copyable text copy instead of a JPG, I could have tried to reproduce and understand. As I am too lazy to type that by hand, I just advise you to read [How to make good reproducible pandas examples](https://stackoverflow.com/q/20109391/3545273) – Serge Ballesta Apr 11 '20 at 13:31
  • It would be so nice if you could post the data as text rather than an image ! :) – Sajan Apr 11 '20 at 13:38
  • apologies! added the data to the question as well. – Mehtab Pathan Apr 11 '20 at 14:02
  • Can you include your expected output too? I'm not clear on what you want at all – Code Different Apr 11 '20 at 20:28

0 Answers0