import pandas as pd import numpy as np
df = pd.DataFrame({'B': range(5)}) df.index = [pd.Timestamp('20190101 09:00:00'), pd.Timestamp('20190101 09:00:02'), pd.Timestamp('20190101 09:00:03'), pd.Timestamp('20190101 09:00:05'), pd.Timestamp('20190101 09:00:06')] df
#here it will create a rolling mean of the previous two records in the dataframe #e.g. (0, (0+1)/2, (1+2)/2, etc) df.rolling(2, min_periods=1).mean()