pandas rolling() function with monthly offset
问题 I'm trying to use the rolling() function on a pandas data frame with monthly data. However, I dropped some NaN values, so now there are some gaps in my time series. Therefore, the basic window parameter gives a misleading answer since it just looks at the previous observation: import pandas as pd import numpy as np import random dft = pd.DataFrame(np.random.randint(0,10,size=len(dt)),index=dt) dft.columns = ['value'] dft['value'] = np.where(dft['value'] < 3,np.nan,dft['value']) dft = dft