Skip to content

Instantly share code, notes, and snippets.

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

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

Select an option

Save dpbac/6ebddb3ec668a8adb92e35d666bb134f to your computer and use it in GitHub Desktop.
from statsmodels.tsa.stattools import kpss
def kpss_test(timeseries):
print ('Results of KPSS Test:')
kpsstest = kpss(timeseries, regression='c', nlags="auto")
kpss_output = pd.Series(kpsstest[0:3], index=['Test Statistic','p-value','Lags Used'])
for key,value in kpsstest[3].items():
kpss_output['Critical Value (%s)'%key] = value
print (kpss_output)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment