I'm attempting to populate a newly created field with values dependent on an existing field.
The new field has text data type. The existing field is double data type. This is the python code I've been trying. It runs, but the values remain
def Reclass(Crime):
if (Hierarchy == 1):
return "Murder-Manslaughter"
elif (Hierarchy == 2):
return "Forcible Rape"
elif (Hierarchy == 3):
return "Robbery"
elif (Hierarchy == 4):
return "Aggravated Assault"
Best Answer
You need to pass the
Hierarchy
field to the function, not theCrime
field.Or even neater, use a
dict
lookup: