Select to view content in your preferred language

Standard Deviation of columns if not zero (or null)

461
2
06-13-2022 09:23 AM
gsmayes
New Contributor

Hi, I'm trying to calculate the standard deviation of three column fields while ignoring zero (or null) values. I've tired various iterations of the expression code below but keep getting syntax errors.

statistics.stdev(d for d in (!ADFgal_2017_N!,!ADFgal_2018_N!,!ADFgal_2019_N!) if d != 0)

0 Kudos
2 Replies
ABishop
MVP Regular Contributor

try setting a definition query on the layer first to remove the null or "0" values.  You may even have blank values that aren't showing up.

Amanda Bishop, GISP
0 Kudos
gsmayes
New Contributor

I can setup a definition query to keep only features where ADFgal_2017_N, ADFgal_2018_N, and ADFgal_2019_N are greater than zero but that's not really what I want. If there are greater than zero values in two columns and zero in a third, I want to calculate the standard deviation of the two values ignoring the zero value.

0 Kudos