运行我的代码后,在jupyter笔记本中没有显示输出或错误吗?

时间:2019-01-26 06:39:23

标签: jupyter-notebook

我正在尝试确定滚动统计信息,但是代码在jupyter笔记本中未显示任何输出或错误。

#Determing rolling statistics
from pandas import Series
from statsmodels.tsa.stattools import adfuller
def test_stationarity(df,ts):
    rol_mean = pd.rolling_mean(ts, window=12)
    rol_std = pd.rolling_std(ts, window=12)
    #Plot rolling statistics:
    orig = plt.plot(ts, color='blue',label='Original')
    mean = plt.plot(rol_mean, color='red', label='Rolling Mean')
    std = plt.plot(rol_std, color='black', label = 'Rolling Std')
    plt.legend(loc='best')
    plt.title('Moving mean & std')
    plt.show(block=False)
    #Perform Dickey-Fuller test:
    test = adfuller(ts, autolag='AIC')
    print (test)

    # to make the results of the test more readable
    dfoutput = pd.Series(test[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)

0 个答案:

没有答案