Automatize autocorrelation in python

I'm trying to automatize my autocorrelation study in Python. My question is: is it possible? Let me explain. I have a time series and I just learnt how to interpret the autocorrelation plot. My question is: given that I need to examine a hundred time series, is it possible to get a result from the data (and not look at plots at all)?

Here's my whole python code, which returns some graphs (for just one time series). What do you advice me to write in order to make python say yes, your time series is autocorrelated or no, your time series is not autocorrelated?

data = pd.DataFrame()
data[diff] = vol_series
data[diff] = data.diff()

ax = data.plot()
ax.legend(ncol=5, 
          loc='upper center',
          bbox_to_anchor=(0.5, 1.0),
          bbox_transform=plt.gcf().transFigure)
for yr in range(2008, 2018):
    ax.axvline(pd.to_datetime(str(yr)+-01-01), color =red, linestyle = --, alpha = 0.2)


from statsmodels.graphics.tsaplots import plot_acf
data[diff].iloc[0] = 0
plot_acf(data[diff])
plt.show()

import numpy as np
def estimated_autocorrelation(x):
    n = len(x)
    variance = x.var()
    x = x-x.mean()
    r = np.correlate(x, x, mode = 'full')[-n:]
    result = r/(variance*(np.arange(n, 0, -1)))
    return result

estimated_autocorrelation(vol_series)

So, I need a function which gets the time series as input and returns me True if it is autocorrelated and False if it is not.

Thank you very much if you reply.

Topic parameter-estimation finance time-series python statistics

Category Data Science

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.