def Reclass(yield) : if (yield <=140) : return "Low" elif (yield > 140 and yield <= 180) : return "Average" elif (yield > 180) :
Solved! Go to Solution.
def Reclass(x): if (x <=140): return "Low" elif (x > 140 and x <= 180): return "Average" elif (x > 180): return "High"
def Reclass(x): if (x <=140): return "Low" elif (x > 140 and x <= 180): return "Average" elif (x > 180): return "High"
cat = Reclass(!yield!)Otherwise you'd be trying to read an integer from a string field.
Your expression block should be:cat = Reclass(!yield!)Otherwise you'd be trying to read an integer from a string field.
or perhaps
cat = Reclass(int(!cat!)) # --- If you need to use the cat value and overwrite the string number with text
# --- Then you would also have to account for possible non numbers text in the Reclass def?
The expression for the Calculate Field tool should simply be (if "cat" is your field name). CAT is also then entered in the Field argument to Calculate Field.
Ted is correct that you'd want to account for non-covered fields. Seems to me it would be safer to create a new field and calculate to that in case something goes wrong.
Reclass(!CAT!)