I am working with ArcPy in ArcGIS Pro 2.7.2. I am using the arcpy.da.TableToNumPyArray function and specifying fields in a list. One of the fields in the source table is defined as a short integer field, but it is tied to an encoded value domain. The underlying values of this domain are valid widths like 2, 4, and 6. The display values of this domain use the inch quotation mark like 2", 4", and 6". Anyway, when I include this field in the call to TableToNumPyArray, I get this error:
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'
When I do not include this field in the function call, everything works just fine. How do I get my numpy array with values like 2, 4, and 6 if the function is creating a short field and trying to put values like 2" into it?
Solved! Go to Solution.
TableToNumPyArray (in_table, field_names, {where_clause}, {skip_nulls}, {null_value})
What options are you using the optional parameters, if any
If you have nulls and you don't provide a conversion, then you will get errors
from arcpy.da import TableToNumPyArray
fc00 = r"C:\Git_Dan\npgeom_bak\Project_npg\npgeom.gdb\Ontario_singlepart"
arr = TableToNumPyArray(fc00, "*")
Traceback (most recent call last):
File "<ipython-input-3-3fe0a3115378>", line 1, in <module>
arr = TableToNumPyArray(fc00, "*")
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'
arr = TableToNumPyArray(fc00, "*", skip_nulls=True) # -- works
TableToNumPyArray (in_table, field_names, {where_clause}, {skip_nulls}, {null_value})
What options are you using the optional parameters, if any
If you have nulls and you don't provide a conversion, then you will get errors
from arcpy.da import TableToNumPyArray
fc00 = r"C:\Git_Dan\npgeom_bak\Project_npg\npgeom.gdb\Ontario_singlepart"
arr = TableToNumPyArray(fc00, "*")
Traceback (most recent call last):
File "<ipython-input-3-3fe0a3115378>", line 1, in <module>
arr = TableToNumPyArray(fc00, "*")
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'
arr = TableToNumPyArray(fc00, "*", skip_nulls=True) # -- works
That worked. There were nulls in the short field, but not in the other fields. It had nothing to do with field type or with a domain. I had seen these two optional parameters, but didn't know the one was required if the underlying data had nulls in it.