1

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

enter image description here

PolyGeo
65.5k29 gold badges115 silver badges349 bronze badges
asked Apr 13, 2016 at 21:53
0

1 Answer 1

4

You have passed wrong parameter to the NumValue function.

It should be:

NumValue(!PCT_B100P!)
answered Apr 13, 2016 at 22:15
1
  • 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. Commented Apr 13, 2016 at 22:18

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.