Skip to content

Instantly share code, notes, and snippets.

@dpbac
Created June 22, 2021 17:46
Show Gist options
  • Select an option

  • Save dpbac/b5d7f8c33017665c8b6a3f54cc58636e to your computer and use it in GitHub Desktop.

Select an option

Save dpbac/b5d7f8c33017665c8b6a3f54cc58636e to your computer and use it in GitHub Desktop.
from statsmodels.tsa.stattools import adfuller
def adf_test(timeseries):
print ('Results of Dickey-Fuller Test:')
dftest = adfuller(timeseries, autolag='AIC')
dfoutput = pd.Series(dftest[0:4], index=['Test Statistic','p-value','#Lags Used','Number of Observations Used'])
for key,value in dftest[4].items():
dfoutput['Critical Value (%s)'%key] = value
print (dfoutput)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment