0

How do i iterate over the '1Min' and get the previous '5Min' value?

                        1Min   5Min
IndexX                              
2016-01-03 23:00:00     5      100     
2016-01-03 23:01:00     6      NaN
2016-01-03 23:02:00     7      NaN
2016-01-03 23:03:00     8      NaN
2016-01-03 23:04:00     9      NaN
2016-01-03 23:05:00     10     200
2016-01-03 23:06:00     11     NaN
2016-01-03 23:07:00     12     NaN
2016-01-03 23:08:00     13     NaN
2016-01-03 23:09:00     14     NaN
2016-01-03 23:10:00     15     300

So if I am at IndexX '2016-01-03 23:08:00' and I wanted to add its '1Min' value (13) with the last '5Min' value (at IndexX '2016-01-03 23:05:00' = 200) or even the one previous to that (at IndexX '2016-01-03 23:00:00' = 100).

Basically for each '1Min' value I want to calculate a moving average on the '5Min' values but starting at a shifted 'IndexX'.

The 1Min and 5Min is arbitrary and I would like to calculate on different timeframes too. So it could be 5Min and 60Min or 1440Min.

john
  • 13
  • 3
  • Will your data in 5Min column remain NaN for minute=1,2,3,4 ? Will values only be populated at every 5th minute ? – Spandan Brahmbhatt Feb 28 '17 at 14:15
  • yes every 5th for 5 Minutes and equally every 15th for 15 Minutes and equally for 60th for 60 minutes.....all the way up to 1440 (Daily) – john Feb 28 '17 at 18:55

0 Answers0