I use Python2.7 on win10 64bit to raise a function. The code is following:
def test_stationarity(timeseries):
#Determing rolling statistics
rolmean = timeseries.rolling(window = 12,center = False).mean()
rolstd = timeseries.rolling(window = 12,center = False).std()
#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.legend(loc='best')
plt.title('Rolling Mean & Standard Deviation')
plt.show(block=False)
#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
when I run this function:
File "<ipython-input-20-ff069253bfd6>", line 17
print 'Results of Dickey-Fuller Test:'
^
SyntaxError: invalid syntax
Why does this error happen?