Error in code for Time Series Forecast (in Python)



Hello I am read the article below:

Time Series Forecast (with Codes in Python)

When I am trying to the same code on my spyder or jupyter I am getting the same error when I run the function
from statsmodels.tsa.stattools import adfuller
def test_stationarity(timeseries):

#Determing rolling statistics
rolmean = pd.rolling_mean(timeseries, window=12)
rolstd = pd.rolling_std(timeseries, window=12)

#Plot rolling statistics:
orig = plt.plot(timeseries, color='blue',label='Original')
mean = plt.plot(rolmean, color='red', label='Rolling Mean')
std = plt.plot(rolstd, color='black', label = 'Rolling Std')
plt.title('Rolling Mean & Standard Deviation')

#Perform Dickey-Fuller test:
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

File “”, line 1, in
runfile(’/Users/apple/Python/Job_Exer/TS_test/’, wdir=’/Users/apple/Python/Job_Exer/TS_test’)

File “/Users/apple/anaconda/lib/python3.6/site-packages/spyder/utils/site/”, line 866, in runfile
execfile(filename, namespace)

File “/Users/apple/anaconda/lib/python3.6/site-packages/spyder/utils/site/”, line 102, in execfile
exec(compile(, filename, ‘exec’), namespace)

File “/Users/apple/Python/Job_Exer/TS_test/”, line 106, in

File “/Users/apple/Python/Job_Exer/TS_test/”, line 100, in test_stationarity
dftest = adfuller(timeseries, autolag=‘AIC’)

File “/Users/apple/anaconda/lib/python3.6/site-packages/statsmodels/tsa/”, line 220, in adfuller
xdall = lagmat(xdiff[:, None], maxlag, trim=‘both’, original=‘in’)

File “/Users/apple/anaconda/lib/python3.6/site-packages/statsmodels/tsa/”, line 375, in lagmat
nobs, nvar = xa.shape

ValueError: too many values to unpack (expected 2)

Any idea why?

I would like to thank you for your time