pandas-rolling

Pandas: Get average of a dynamic number of rows

Pandas: Get average of a dynamic number of rows Question: I have a dataframe with a timestamp column/index and I am calculating the moving average over the last 5 seconds. df[‘Mid-Price’].rolling(window=time_diff, min_periods=1, closed=’both’).mean() So far so good. Now I also need to calculate the moving average for the next 5 seconds. However, my timestamps are …

Total answers: 1