0

I am having trouble with a field calculator statement! I am trying to reclassify an attribute column based on their values. So if value =0 then make it 14, if value < 3 make it 11, if value >3 and < 9 then make it 12 and if none of the above make it 13.

I wrote this but 12 doesnt ever show up when i know it must!

My Code:

CODE BLOCK
def reclass(x):
     if x == 0:
          x = 14
     elif x <= 3:
          x = 11
     elif (x < 4 and x > 9):
          x = 12
     else:
          x = 13
     return x
field= reclass(attribute)
1
  • 1
    x can never be both less than 4 and greater than 9 at the same time. – user2856 Mar 22 at 2:00
1

Replace

elif (x < 4 and x > 9):

with

elif (x >3 and x < 9):

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.