变量已赋值,但返回“名称错误”

2024-10-06 10:29:48 发布

您现在位置:Python中文网/ 问答频道 /正文

result = adfuller(df["Milk, lbs/cow"])
def adf_check(time_series):

    result = adfuller(time_series)
    print("Augmented Dickey Fuller Test")
    labe = ['ADF Test Statistic', 'p-value', '# of lags', '# of Observations']

for value, label in zip (result, labe):
    print(label+ ' : ' + str(value))

我得到这个错误,因为变量定义得很清楚。有什么原因不能运行吗

NameError            
Traceback (most recent call last)
<ipython-input-51-fa1014e81050> in <module>
      6     labe = ['ADF Test Statistic', 'p-value', '# of lags', '# of Observations']
      7 
----> 8 for value, label in zip (result, labe):
      9     print(label+ ' : ' + str(value))
     10 

NameError: name 'labe' is not defined

Tags: ofintesttimevalueresultstatisticlabel
1条回答
网友
1楼 · 发布于 2024-10-06 10:29:48
result = adfuller(df["Milk, lbs/cow"])
def adf_check(time_series):

    result = adfuller(time_series)
    print("Augmented Dickey Fuller Test")
    labe = ['ADF Test Statistic', 'p-value', '# of lags', '# of Observations']

    # indentation matters in python
    for value, label in zip (result, labe):
        print(label+ ' : ' + str(value))

相关问题 更多 >