Looking for some help. I have a continuous variable (PCT_B100P) of the percentage of folks in a census tract that are under the 100% federal poverty line. I'm trying to use this variable to assign a categorical variable (POVCAT)to the census tract. If the value is below, between, or above certain limits it will determine what category the record gets. I'm not getting any errors in my code, buy it's only calculating the first category level 1, and nothing else. Here is my code.
def NumValue( PCT_B100P ):
if (PCT_B100P <5):
return 1
elif (PCT_B100P >= 5 and PCT_B100P <10):
return 2
elif (PCT_B100P >= 10 and PCT_B100P <20):
return 3
elif (PCT_B100P > 20):
return 4
Expression:
NumValue(!POVCAT!)
any idea as to what I'm doing wrong? I'm quite new to Python. Below is an image of my issue
1 Answer 1
You have passed wrong parameter to the NumValue function.
It should be:
NumValue(!PCT_B100P!)
-
Also, while the term PCT_B100P in the line: "def NumValue( PCT_B100P ):" is descriptive, it may be less confusing (and certainly faster to type) to just use x or another variable name that doesn't correspond to an attribute field name.Mike Bannister– Mike Bannister2016年04月13日 22:18:16 +00:00Commented Apr 13, 2016 at 22:18
Explore related questions
See similar questions with these tags.