title: Pandas monthly rolling window
body: <p>I am looking to do a 'monthly' rolling window on daily data grouped by a category. The code below does not work as is, it leads to the following error:</p>
  
  <pre><code>ValueError: &lt;DateOffset: months=1&gt; is a non-fixed frequency
  </code></pre>
  
  <p>I know that I could use '30D' offset, however this would shift the date over time.</p>
  
  <p>I'm looking for the sum of a window that spans from the x-th day of a month to that same x-th day of the J-th month. E.g. with J=1: 4th of July to 4th of August, 5th of July to 5th of August, 6th of July to 6th of August etc</p>
  
  <p>I've been trying to figure this out for a few days now. Any suggestions or tipps would be <strong>very</strong> appreciated. Happy New Year. </p>
  
  <p>MRE:</p>
  
  <pre><code>import pandas as pd
  from io import StringIO
  
  data = StringIO(
  """\
  date          logret       category
  2014-03-25    -0.01           A
  2014-04-05    -0.02           A
  2014-04-15    -0.03           A
  2014-04-25    0.01            B
  2014-05-05    0.03            B
  2014-05-15    -0.01           A
  2014-05-25    0.04            B
  """
  )
  
  df = pd.read_csv(data,sep="\s+",parse_dates=True,index_col="date")
  
  J=1
  
  df.groupby(['category'])['logret'].rolling(pd.DateOffset(months=J),min_periods=J*20).sum() 
  </code></pre>