I would like to calculate a mean and STD for one field in my feature class. I am python beginner.
I have found great source calcualting mean and STD for multiple fields, however, the STD calculation seems not correct: Is it possible to calculate statistics across multiple fields in arcpy? After applying the code, my STD is "None" which is not true for real data.
import math, itertools, arcpy FC = arcpy.GetParameterAsText(0) field = "RASTERVALU" #Flatten a list of lists # do I even need this if I have just one field? How to replace this? def flatten(list_lists): return list(itertools.chain.from_iterable(list_lists)) #Definition of standard deviation, seems not working... def std(x): pass #read values from fields and flatten vals = flatten([r for r in row] for row in arcpy.da.SearchCursor(FC, field)) # print results print "mean is " + str(sum(vals) / len(vals)) print "std is" + str(std(vals)) # STD gives back None
How to correctly calculate my STD? I need it to save as a value, which I can use further in the code.