title: How to get moving average of past months in Pandas
body: <p>I have a data set with first column is the Date and Second column is the Price.
  The Date is trading days.</p>
  
  <p><a href="https://i.stack.imgur.com/rTwK5.png" rel="noreferrer"><img src="https://i.stack.imgur.com/rTwK5.png" alt="enter image description here"></a></p>
  
  <p>I want to return a table looks like this:</p>
  
  <p><a href="https://i.stack.imgur.com/rTryL.png" rel="noreferrer"><img src="https://i.stack.imgur.com/rTryL.png" alt="enter image description here"></a></p>
  
  <p>Where the date is each Month starting from 2006, price MA is the average price of past N months.(N = [1,2,3,4,5,6])</p>
  
  <p>So for example: If I want N = 1 at Jan.1 2006
  Ma should be the average price from December last year
  If N =2
  Ma should be the average price from Nov and December last year</p>
  
  <p>I have read some solution about Extract month from datetime and groupby.
  But don't know how to put them up together.</p>