Help debug this Python field calculator script

1121
4
Jump to solution
03-17-2017 08:35 AM
MichaelLenore1
New Contributor III

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"
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
Tags (1)
0 Kudos
1 Solution

Accepted Solutions
JoshuaBixby
MVP Esteemed Contributor

An empty string is '', not NoneNone is what is returned when a field is NULL.

View solution in original post

4 Replies
JoshuaBixby
MVP Esteemed Contributor

When you say "empty," do you mean NULL or an empty string?  If "No data" isn't being returned now, what is?

0 Kudos
MichaelLenore1
New Contributor III

Empty string. Now returns "Other."

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

An empty string is '', not NoneNone is what is returned when a field is NULL.

MichaelLenore1
New Contributor III

Aha. Thought I'd tried ==' ' but I guess I hadn't - that did the trick. thanks!

0 Kudos