If I got you right, you can try resample your data first and then use rolling function. To show how it works I have made an example:
First, I have generated some data:
df = pd.DataFrame(data = [[i] for i in range(0,100)], columns=['data'])
df['date'] = pd.date_range(start='11.02.2020', freq='w', periods= 100)
df = df.set_index('date')
Here are some rows from this data:
data
date
2020-11-08 0
2020-11-15 1
2020-11-22 2
2020-11-29 3
2020-12-06 4
... ...
2022-09-04 95
2022-09-11 96
2022-09-18 97
2022-09-25 98
2022-10-02 99
Then we apply the resampling function.
resampled_df = df.resample('m').sum()
So now, my dataframe looks like:
data
date
2021-09-30 98.272727
2021-10-31 120.000000
2021-11-30 137.454545
2021-12-31 153.818182
2022-01-31 176.727273
2022-02-28 194.181818
2022-03-31 211.636364
2022-04-30 226.454545
2022-05-31 250.909091
2022-06-30 268.363636
2022-07-31 290.181818
2022-08-31 307.636364
2022-09-30 320.454545
2022-10-31 310.000000
And then we can apply rolling function with mean:
result = resampled_df.rolling(window=11).mean()
window = 11 means that we use 11 months window. But after that we will have some NaN values, because there isn't enough data for first 10 values to count mean for past 11 months. So you could drop them, if you like.
result = result.dropna()
Here is the result:
data
date
2021-09-30 98.272727
2021-10-31 120.000000
2021-11-30 137.454545
2021-12-31 153.818182
2022-01-31 176.727273
2022-02-28 194.181818
2022-03-31 211.636364
2022-04-30 226.454545
2022-05-31 250.909091
2022-06-30 268.363636
2022-07-31 290.181818
2022-08-31 307.636364
2022-09-30 320.454545
2022-10-31 310.000000
Each row now means the average of past 11 months.