xanstorm
xanstorm

Reputation: 33

Variable is assigned but comes back "Name Error"

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))

I get this error tho the variable is clearly defined. Any reason this is not running?

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

Upvotes: 0

Views: 426

Answers (1)

Harshal Parekh
Harshal Parekh

Reputation: 6017

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))

Upvotes: 1

Related Questions