Hello, I am working on wind data and am trying to reclassify the wmo_wind field into a new field.
Please help because I cannot figure out why it is not valid.
The query is if the value in wmo_wind is as the values shown in pink circle, they will be reclassified to categories 1 to 5 respectively.
def reclass (wmo_wind): if wmo_wind < 96: return '1' elif wmo_wind > 96 and < 111: return '2' elif wmo_wind > 111 and < 130: return '3' elif wmo_wind > 130 and < 157: return '4' elif wmo_wind > 157: return '5'
What is the actual error?
A couple of problems:
When you perform a field calculation, the new value will be applied to all records. Your logic as shown is better suited for an update cursor where you would be stepping through each record, applying the conditional to a single cursor row.
You are returning a text type of value (as indicated by the quotes), yet you are treating the values as integers.