我为什么会出现ValueError:太多值无法解包(预期2)?

时间:2019-07-02 11:06:08

标签: python-3.x

my df'td'是一个时间序列数据,其中索引月份数为1,性能值为0-1的列。我正在尝试进行平稳性测试

'''

def stationarity_test(timeseries):
    """"Augmented Dickey-Fuller Test
    Test for Stationarity"""
    from statsmodels.tsa.stattools import adfuller
    print("Results of Dickey-Fuller Test:")
    df_test = adfuller(timeseries, autolag = "AIC")
    df_output = pd.Series(df_test[0:4],
                          index = ["Test Statistic", "p-value", "#Lags Used",
                                   "Number of Observations Used"])
    print(df_output)
stationarity_test(td)

'''

收到错误: 迪基-富勒测试的结果:

Traceback (most recent call last):

  File "<ipython-input-143-69a68080d36a>", line 12, in <module>
    stationarity_test(td)

  File "<ipython-input-143-69a68080d36a>", line 6, in stationarity_test
    df_test = adfuller(timeseries, autolag = "AIC")

  File "C:\ProgramData\Anaconda3\lib\site-packages\statsmodels\tsa\stattools.py", line 221, in adfuller
    xdall = lagmat(xdiff[:, None], maxlag, trim='both', original='in')

  File "C:\ProgramData\Anaconda3\lib\site-packages\statsmodels\tsa\tsatools.py", line 397, in lagmat
    nobs, nvar = xa.shape

ValueError: too many values to unpack (expected 2)

0 个答案:

没有答案