Name error #584
-
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hi @allenmoench, it looks to me like you have a bit of an indentation problem here. Remember that indentation is how Python knows whether something is inside or outside a function -- and also that variables defined inside a function are not available outside! So, in this case, bounds_gdf is being referenced outside the function (it's unindented), but it's only defined at all because it is listed as a function parameter. Outside the function, it's called denver_redlining_gdf. Same think with da -- you define that variable inside the function, not outside, but the code referencing it is outside. Good news is, I think your code will work if you indent lines 21-31 one more step! |
Beta Was this translation helpful? Give feedback.
-
Got it to work, thanks!! It was the indentation. |
Beta Was this translation helpful? Give feedback.
Hi @allenmoench, it looks to me like you have a bit of an indentation problem here. Remember that indentation is how Python knows whether something is inside or outside a function -- and also that variables defined inside a function are not available outside! So, in this case, bounds_gdf is being referenced outside the function (it's unindented), but it's only defined at all because it is listed as a function parameter. Outside the function, it's called denver_redlining_gdf.
Same think with da -- you define that variable inside the function, not outside, but the code referencing it is outside.
Good news is, I think your code will work if you indent lines 21-31 one more step!