rolling/sum np.nanargmax, , :
import numpy as np
import pandas as pd
df = pd.DataFrame({'dt': ['2017-01-01 12:00:00', '2017-01-01 12:01:00', '2017-01-01 12:02:00', '2017-01-01 12:03:00', '2017-01-01 12:04:00', '2017-01-01 12:05:00', '2017-01-01 12:06:00', '2017-01-01 12:07:00', '2017-01-01 12:08:00', '2017-01-01 12:09:00', '2017-01-01 12:10:00', '2017-01-01 12:11:00', '2017-01-01 12:12:00', '2017-01-01 12:13:00', '2017-01-01 12:14:00', '2017-01-01 12:15:00'], 'val': [33, 42, 44, 6, 70, 94, 42, 97, 12, 11, 66, 71, 25, 23, 39, 25]})
df.index = df.index*10
N = 3
idx = df['val'].rolling(window=N).sum()
i = np.nanargmax(idx) + 1
print(df.iloc[i-N : i])
dt val
50 2017-01-01 12:05:00 94
60 2017-01-01 12:06:00 42
70 2017-01-01 12:07:00 97
iloc . loc . ,
i-N, i , df.iloc[i-N : i]
(sub-DataFrame) N. , df.loc[i-N, i]
N, .
DataFrame, df.loc , df.index
.