I recently came up with an error in a script I am working with in Python for ArcGIS 10.1. The strange thing about it is that this script works for some files and not for others. Any ideas as to why this is happening?
The part of the code I get the error in is:
data_elevation= with arcpy.da.SearchCursor(path, "Elevation") as sCursor: for row in sCursor: data_elevation.append(row) var_elevation = numpy.var(data_elevation)
path in code stands for a FeatureClass (e.g. C:/test_fc.shp) containing field "Elevation" (e.g. 140, 140, 141, 150, ....).
Traceback (most recent call last): File "...", line 90, in var_elevation = numpy.var(data_elevation) File "C:\Python27\ArcGIS10.1\lib\site-packages\numpy\core\fromnumeric.py", line 2561, in var return _wrapit(a, 'var', axis, dtype, out, ddof) File "C:\Python27\ArcGIS10.1\lib\site-packages\numpy\core\fromnumeric.py", line 37, in _wrapit result = getattr(asarray(obj),method)(*args, **kwds) TypeError: unsupported operand type(s) for +: 'int' and 'NoneType'