SyntaxError:print语句中Python2.7的语法无效

时间:2017-04-23 14:19:29

标签: python python-2.7

我在win10 64bit上使用Python2.7来提升功能。 代码如下:

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

当我运行此功能时:

File "<ipython-input-20-ff069253bfd6>", line 17
    print 'Results of Dickey-Fuller Test:'
                                         ^
SyntaxError: invalid syntax

为什么会发生此错误?

0 个答案:

没有答案