I have a pandas dataframe with monthly data that I want to compute a 12 months moving average for. Data for for every month of January is missing, however (NaN), so I am usi
The real key is having min_periods=1. Also, as of version 18, the proper calling is with a Rolling object. Therefore, your code should be
min_periods=1
data["variable"].rolling(min_periods=1, center=True, window=12).mean().
data["variable"].rolling(min_periods=1, center=True, window=12).mean()