title: pandas rolling functions with time groupby
body: <p>here is my problem.
  What I have is a DataFrame as follows:</p>
  
  <pre><code>df:
  
  2013-10-24      1
  2013-10-25      2
  2013-11-27      3 
  2013-11-28      4
  2013-12-01      5 
  2013-12-02      6
  </code></pre>
  
  <p>What I want is a DataFrame such like this:</p>
  
  <p>rolling_mean(df, window='1M'):</p>
  
  <pre><code>2013-10      1.5
  2013-11      3.5
  2013-12      5.5 
  </code></pre>
  
  <p>rolling_mean(df, window='2M'):</p>
  
  <pre><code>2013-10      NAN
  2013-11      2.5
  2013-12      4.5 
  </code></pre>
  
  <p>rolling_mean(df, window='3M'):</p>
  
  <pre><code>2013-10      NAN
  2013-11      NAN
  2013-12      3.5 
  </code></pre>
  
  <p>rolling_mean(df, window='1Y'):</p>
  
  <pre><code>2013-10      NAN
  2013-11      NAN
  2013-12      NAN
  </code></pre>
  
  <p>where 1M is '1 month', 2M is '2 months'. The window is not a int value, but a time interval such as '1D', '3M', '1Y' and so on. The function could groupby the dataframe by the time unit such as 'D', 'M', 'Y', and then rolling the dataframe through the number before the time unit such as 1, 3...</p>
  
  <p>I need a rolling function such like this?
  Could anybody help me? Did I give a clear description?
  Many thanks.</p>
  
  <p><strong>Update:</strong></p>
  
  <p>I still have a puzzle.
  I need to implement such a function which could calculate rolling standard deviation of every day, not resampled by month, but the window step unit is weighed by month.</p>
  
  <p>In this scenario, 
  what I have is also 
  df:</p>
  
  <pre><code>2013-10-24      1
  2013-10-25      2
  2013-11-27      3 
  2013-11-28      4
  2013-12-01      5 
  2013-12-02      6
  </code></pre>
  
  <p>pd.rolling_std(df.resample('1M'),window=1):</p>
  
  <p>The result is </p>
  
  <pre><code>2013-10    NAN
  2013-11    NAN 
  2013-12    NAN
  </code></pre>
  
  <p>what I really is a dataframe like this(window = 1 ): </p>
  
  <pre><code>2013-10    0.5
  2013-11    0.5 
  2013-12    0.5
  </code></pre>
  
  <p>The first 0.5 is the standard deviation which can be calculated by np.sqrt([1,2]) from October.
  Also 0.5 from the others are from [3,4] and [5,6].
  However, no matter what how = 'xxx' method in the resample function, the result is not right.
  The objective result of 2months is, </p>
  
  <p>df (window = 2 ): </p>
  
  <pre><code>2013-10    NAN
  2013-11    1.1180 
  2013-12    1.1180
  </code></pre>
  
  <p>The first 1.1180 is the standard deviation which can be calculated by np.sqrt([1,2,3,4]) from October and November.
  1.1180 from 2013-12 are from [3,4,5,6] of 2013-11 and 2013-12.</p>
  
  <p>p.s. 
  The standard deviation is one of my functions which I want to implement rolling...
  THANK YOU~</p>