title: Calculating rolling correlation of pandas dataframes
body: <p>Is it possible to use the rolling window and correlation function in pandas to do a correlation of a shorter dataframe or series to a longer one, and get the result along the longer time series?  Basically doing what the numpy.correlate method does, but instead of cross-correlation, doing pairwise correlations. </p>
  
  <pre><code>x= [0,1,2,3,4,5,4,7,6,9,10,5,6,4,8,7]
  y= [4,5,4,5]
  print(x)
  print(y)
  corrs = []
  for i in range(0,len(x)-3):
      corrs.append( np.corrcoef(x[i:i+4],y)[0,1] )
  </code></pre>
  
  <p>with a result of:</p>
  
  <pre><code>[0.4472135954999579, 0.4472135954999579, 0.4472135954999579, 0.0, 0.8164965809277259, -0.4472135954999579, 0.8320502943378437, 0.0, -0.24253562503633297, 0.24253562503633297, -0.7683498199278325, 0.8451542547285166, -0.50709255283711]
  </code></pre>
  
  <p>Every combination of windows and pairwise either gives a series of NAN or a "ValueError: Length mismatch". In the simple test case I made, its always NAN or a single result, but no window.</p>
  
  <pre><code>x = pd.DataFrame(x)
  y = pd.DataFrame(y)
  
  corr = y.rolling(np.shape(y)[0]).corr(x)
  print(corr)
  corr = y.rolling(np.shape(x)[0]).corr(x)
  print(corr)
  corr = x.rolling(np.shape(x)[0]).corr(y)
  print(corr)
  corr = x.rolling(np.shape(y)[0]).corr(y)
  print(corr)
  corr = y.rolling(np.shape(y)[0]).corr(x,pairwise=True)
  print(corr)
  corr = y.rolling(np.shape(x)[0]).corr(x,pairwise=True)
  print(corr)
  corr = x.rolling(np.shape(x)[0]).corr(y,pairwise=True)
  print(corr)
  corr = x.rolling(np.shape(y)[0]).corr(y,pairwise=True)
  print(corr)
  </code></pre>