Python question regarding Null Values

3087
2
Jump to solution
01-29-2015 07:02 AM
MattFolley__DOIT_
New Contributor

Trying to calculate a field within a model builder process, and I am getting returns I was not expecting. I am trying to have the Null values calculated as 0s (Number field). Now, the non-Null values are being calculated to 0s and leaving the Null values.

0 Kudos
1 Solution

Accepted Solutions
VandanaRaghunathan
New Contributor III

Hello Matt,

You probably need to add an else in there and check for the field equals <null>. Something like:

expression:

nullfill(!FREQUENCY!)

codeblock:

def nullfill(value):
    if value == None:
        return 0
    else:
        return value

View solution in original post

2 Replies
VandanaRaghunathan
New Contributor III

Hello Matt,

You probably need to add an else in there and check for the field equals <null>. Something like:

expression:

nullfill(!FREQUENCY!)

codeblock:

def nullfill(value):
    if value == None:
        return 0
    else:
        return value
MattFolley__DOIT_
New Contributor

That did the trick! Thank you for the help.

0 Kudos