python-3.x - 为什么我收到 ValueError: too many values to unpack (expected 2)?
问题描述
我的 df 'td' 是一个时间序列数据,索引月份和一列的性能值介于 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)
'''
收到的错误:Dickey-Fuller 测试的结果:
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)
解决方案
推荐阅读
- c# - 如何在Android中以xamarin形式实现复选框的不确定状态
- lua - Lua - 按字母顺序重新排列字符串
- blockchain - Corda 中的自定义事件
- javascript - Bootstrap 侧边栏最后一个链接不显示在主板视图中
- javascript - 如何测试css类属性?
- go - golang 使用 gcc 而不是 g++ 构建
- swift - 声明后不可访问的可观察对象中的变量(SwiftUI)
- python - pymongo db.collection.find().count 每次返回 1
- python - 是否可以使用 tkinter 中的标签和框架向自定义表格添加垂直滚动条?
- javascript - 样式化组件不包装另一个样式化组件