Pandas -selecting data from last minute of hour for 24hr data

0 votes
asked Jan 12 by wazzahenry

Pandas beginner here.

I have a 24 hour time series in minutes, with a cumulative value in column A:

Time                Energy
11-01-2017 10:14    19.14634168
11-01-2017 10:15    19.14702618
11-01-2017 10:16    19.14719065
11-01-2017 10:17    19.14719065
…   
11-01-2017 23:56    19.47694149
11-01-2017 23:57    19.4771605
11-01-2017 23:58    19.47753776
11-01-2017 23:59    19.47801377

I would like to know what the value of column A is at the end of every hour (dd-mm-yyy hh:59), and save this data in a csv file, with an extra colum added to show the hour. The result would look like this:

   Time             Hour  Energy
   11-01-2017 00:59    1     02.0000000
   11-01-2017 01:59    2     04.1234554
   11-01-2017 02:59    3     06.1234554
   ...
   11-01-2017 23:59    24    19.4780137

Should I iterate the timeseries based on the seconds value of 59, or is it easier to just pluck the value in Column A every 60 rows, given there will always be 1440 rows (1440 minutes)?

Please log in or register to answer this question.

...