title: Calculate rolling correlation with pandas
body: <p>I have a list of 10 stocks differentiated by PERMNO. I would like to group those stocks by PERMNO and calculate the rolling correlation between the stock return (RET) for each PERMNO with the market return (vwretd). The code I am trying is below. </p>
  
  <pre><code>CRSP['rollingcorr'] = CRSP.groupby('PERMNO').rolling_corr(CRSP['RET'],CRSP['vwretd'],10)
  </code></pre>
  
  <p>The error I am getting is below.</p>
  
  <pre><code>---------------------------------------------------------------------------
  AttributeError                            Traceback (most recent call last)
  &lt;ipython-input-32-c18e1ce01302&gt; in &lt;module&gt;()
        1 #CRSP['rollingcorr'] = CRSP.rolling_corr(CRSP['vwretd'],CRSP['RET'],120)
  ----&gt; 2 CRSP['rollingmean'] = CRSP.groupby('PERMNO').rolling_corr(CRSP['vwretd'],10)
        3 CRSP.head(20)
  
  C:\Users\rebortz\Anaconda\lib\site-packages\pandas\core\groupby.pyc in __getattr__(self, attr)
      296 
      297         raise AttributeError("%r object has no attribute %r" %
  --&gt; 298                              (type(self).__name__, attr))
      299 
      300     def __getitem__(self, key):
  
  AttributeError: 'DataFrameGroupBy' object has no attribute 'rolling_corr'
  </code></pre>
  
  <p>please help!</p>
  
  <p>Thanks</p>