I'm fairly certain that this is a VERY simple issue but I cannot figure it out as I'm a beginner. I'm trying to use a Python code to populate a new field in the attribute table based on values in another. I've added a new numeric field called BusTypeNumeric2 and would like to reclassify the existing numeric field BusTypeNumeric to populate it. BusTypeNumeric ranges from 1 to 5, and I would like to reclassify so that 1=1, 2=1, 3=2, 4=2, and 5=3.
My expression(?) is:
BusTypeNumeric2=reclass(!BusTypeNumeric!)
The code block is:
def reclass(BusTypeNumeric):
if (BusTypeNumeric == '1'):
return '1'
elif (BusTypeNumeric == '2'):
return '1'
elif (BusTypeNumeric == '3'):
return '2'
elif (BusTypeNumeric == '4'):
return '2'
elif (BusTypeNumeric == '5'):
return '3'
When I verify the expression it comes back valid and when I run it it says that the operation was completed, but it doesn't change anything in the target field; BusTypeNumeric2 values are still all <Null> afterward. I've heard that if the fields are numeric, then you can use one = instead of two, but when I use one =, the code block comes up as invalid and I'm told to use two.
Any insight as to what I may be doing wrong? I'm happy to provide more information!