Quantcast
Channel: Forums - Geoprocessing
Viewing all articles
Browse latest Browse all 1952

Python None, Null, and Zero

$
0
0
Hi There,

I'm performing some calculations in a table where I want to filter out Null values, but keep values of zero. I am trying to use the Python Filter function, but am having some issues. When I specify that values of "None" be filtered, zero values are also filtered. I would like to only filter Null values. This is confusing me because any literature I read says that the Python None value is equal to Null.

Here's a simple form of my Python script (Pre-logic Script) in field calculator:

def trial(f1,f2):
list = [f1,f2]
l1 = len(filter(None,list))
return l1

The code above runs fine, but returns undesired lengths when f1 or f2 are zero.

Can anyone tell me what I am doing wrong, or another simple way of filtering out Null values and not zero values? Thanks for your insight!

Happy New Year!
Nick

Viewing all articles
Browse latest Browse all 1952

Trending Articles