To find the maximum over the last 300 seconds:
import pandas as pd
# 16 to 17 minutes of time-series data.
df = pd.DataFrame(range(10000))
df.index = pd.date_range(1, 1000000000000, 10000)
# maximum over last 300 seconds. (outputs 9999)
df[0].rolling('300s').max().tail(1)
How can I exclude the most recent 30s
from the rolling calculation? I went the max between -300s
and -30s
.
So, instead of 9999
being outputted by the above, I want something like 9700
(thereabouts) to be displayed.