title: Calculate autocorrelation as a function of lag in Python
body: <p>In python (+ pandas/numpy/scipy/statsmodels) Is there a function to return the autocorrelations wrt lag? Does anything like this exist ready made as a library function?</p>
  
  <p>To avoid confusion, I want the following, just I don't want to plot it but I want it returned as a series (pd.Series or pd.DataFrame):</p>
  
  <pre><code>import numpy as np
  import pandas as pd
  from statsmodels.graphics.tsaplots import plot_acf
  from matplotlib import pyplot as plt
  plt.ion()
  s = pd.Series(np.sin(range(1,100))) + pd.Series(np.random.randn(99))
  plot_acf(s)
  </code></pre>
  
  <p>Effectively, I want what <code>pd.Series.autocorr()</code> returns but I want a series rather than a scalar returned where the series contains the autocorrelation for various lags.</p>
  
  <p>Edit:</p>
  
  <p>One way to achieve the above is to do:</p>
  
  <pre><code>pd.Series([s.autocorr(i) for i in range(0,s.shape[0]-1)], index=range(0,s.shape[0]-1))
  </code></pre>