df.X.groupby([df.index.hour, df.index.minute]).apply(lambda g: g.rolling(
    window=5).sum()).tail()
Pandas: how to compute the rolling sum of a variable over the last few days but only at a given hour?