hello, I have a polyline shapefile, and I need to calculate the mean value of one column of its attribute table using arcpy.
Any suggestion?
import numpy as np from arcpy.da import SearchCursor values = np.mean([row[0] for row in SearchCursor(fc, "Shape_Length")])
An equivalent but slower method, if there are no nulls (an extra hoop to jump through is necessary if there are nulls)
I will try this one.
Thanks a lot.
or perhaps
import numpy as np from arcpy.da import TableToNumPyArray fc = r"C:\Git_Dan\npgeom_bak\Project_npg\npgeom.gdb\Ontario_singlepart" arr = TableToNumPyArray(fc, "Shape_Length", skip_nulls=True) np.mean(arr["Shape_Length"]) 84684.37997765756
As in Summary Statistics (Analysis)—ArcGIS Pro | Documentation
or is it something different you are looking for?
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.