已分配变量,但返回“名称错误”

问题描述 投票:0回答:1
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
python variables
1个回答
1
投票
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))
© www.soinside.com 2019 - 2024. All rights reserved.