title: Pandas DataFrame custom rolling function that sees index
body: <p>I want to apply an offset rolling window function on a DataFrame with a date index.  Here's an example:</p>
  
  <pre><code>rng = pd.date_range('2017-01-03', periods=20, freq='W')
  df = pd.DataFrame(np.random.randn(20), rng, columns=['Val'])
  df.index.name = 'Date'
  r = df.rolling('15D')
  </code></pre>
  
  <p>This produces a DataFrame <code>df</code> like:</p>
  
  <pre><code>                 Val
  Date                
  2017-01-08  0.592210
  2017-01-15 -1.243938
  2017-01-22 -0.713988
  2017-01-29  1.554777
  ...
  </code></pre>
  
  <p>But I can't figure out how to see the Date associated with each Val in any function I apply to the <code>Rolling</code> window.  For example, the following:</p>
  
  <pre><code>def f(data=None): # I really want to reference the Date associated with each Val in here!
      print('f(%s) data=%s' % (str(type(data)), data))        
      return 1
  r.apply(lambda x: f(x))
  </code></pre>
  
  <p>shows that all I get to see is an <code>ndarray</code> for each call:</p>
  
  <pre><code>f(&lt;class 'numpy.ndarray'&gt;) data=[0.59220959]
  f(&lt;class 'numpy.ndarray'&gt;) data=[ 0.59220959 -1.24393841]
  f(&lt;class 'numpy.ndarray'&gt;) data=[ 0.59220959 -1.24393841 -0.71398767]
  f(&lt;class 'numpy.ndarray'&gt;) data=[-1.24393841 -0.71398767  1.55477737]
  ...
  </code></pre>
  
  <p>Is there a way to invoke a time offset rolling window on a DataFrame in such a way that the aggregation function sees the index associated with each value in the window?</p>
  
  <p>E.g., so that I can apply a function that sees something like:</p>
  
  <pre><code>f(&lt;class 'DataFrame'&gt;) data=[{2017-01-08, 0.59221}]
  f(&lt;class 'DataFrame'&gt;) data=[{2017-01-08, 0.59221}, {2017-01-15, -1.243938}]
  ...
  </code></pre>