I can't get this to work. I want it to return "No Data" if the field PROP_CLASS is empty (see line 32). As things stand it returns "Other." It works otherwise. Any ideas?
def CATEGORY(prop_class):
if '200' <= prop_class <= '283':
return "Residential"
elif '310' <= prop_class <='312':
return "Residential"
elif prop_class == '322':
return "Residential"
elif '410' <= prop_class <= '413':
return "Residential"
elif prop_class == '416':
return "Residential"
elif prop_class == '693':
return "Residential"
elif prop_class == '300':
return "Public/Vacant"
elif '313' <= prop_class <= '321':
return "Public/Vacant"
elif '323' <= prop_class <= '380':
return "Public/Vacant"
elif prop_class == '531':
return "Public/Vacant"
elif prop_class == '552':
return "Public/Vacant"
elif prop_class == '560':
return "Public/Vacant"
elif '590' <= prop_class <= '593':
return "Public/Vacant"
elif prop_class == '695':
return "Public/Vacant"
elif '900' <= prop_class <= '994':
return "Public/Vacant"
elif prop_class is None:
return "No Data"
else:
return "Other"
Solved! Go to Solution.
An empty string is '', not None. None is what is returned when a field is NULL.
When you say "empty," do you mean NULL or an empty string? If "No data" isn't being returned now, what is?
Empty string. Now returns "Other."
An empty string is '', not None. None is what is returned when a field is NULL.
Aha. Thought I'd tried ==' ' but I guess I hadn't - that did the trick. thanks!