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?
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):
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)
Effectively, I want what pd.Series.autocorr()
returns but I want a series rather than a scalar returned where the series contains the autocorrelation for various lags.
Edit:
One way to achieve the above is to do:
pd.Series([s.autocorr(i) for i in range(0,s.shape[0]-1)], index=range(0,s.shape[0]-1))