-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GeoAccessor.from_table Returns TypeError on SHORT Field with NULL and skip_nulls=False #829
Comments
@bixb0012 Thanks for reporting this, I'll take a look. |
@bixb0012 what version of ArcGIS Pro are you using? |
I am using Pro 2.7 beta 1 that has ArcGIS API for Python 1.8.3 It has to do with NULLs in SHORT fields. If I isolate a SHORT field and leave pd.DataFrame.spatial.from_table(tbl, fields="shosrt_field", skip_nulls=False)
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\features\geo\_accessor.py", line 2422, in from_table
return from_table(filename, **kwargs)
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\features\geo\_io\fileops.py", line 257, in from_table
null_value=null_value))
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType' |
ok, thanks, this is good information. The root cause is actually: |
Any chance you can share your table? |
Regarding the original issue, Setting the original/ >>> import os
>>> import pandas as pd
>>> import arcpy
>>> from arcgis.features import GeoAccessor, GeoSeriesAccessor
>>>
>>> recs = iter([
... ["Line 1", 1],
... ["Line 2", 2],
... ["Line 3", 3],
... [None, 4],
... ["Line 5", None]
... ])
>>>
>>> # create table
>>> sgdb = arcpy.env.scratchGDB
>>> tbl = arcpy.CreateTable_management(
... *os.path.split(arcpy.CreateScratchName(workspace=sgdb))
... )
>>> res = arcpy.AddField_management(tbl, "TXT_FLD", "TEXT")
>>> res = arcpy.AddField_management(tbl, "SHORT_FLD", "SHORT")
>>>
>>> # populate with 3 non-null records, check GeoAccessor.from_table results
>>> with arcpy.da.InsertCursor(tbl, ["TXT_FLD", "SHORT_FLD"]) as cur:
... for _ in range(3):
... res = cur.insertRow(next(recs))
...
>>> pd.DataFrame.spatial.from_table(tbl, skip_nulls=False)
OBJECTID TXT_FLD SHORT_FLD
0 1 Line 1 1
1 2 Line 2 2
2 3 Line 3 3
>>>
>>> # populate with 1 record with NULL text field, check GeoAccessor.from_table results
>>> with arcpy.da.InsertCursor(tbl, ["TXT_FLD", "SHORT_FLD"]) as cur:
... res = cur.insertRow(next(recs))
...
>>> pd.DataFrame.spatial.from_table(tbl, skip_nulls=False)
OBJECTID TXT_FLD SHORT_FLD
0 1 Line 1 1
1 2 Line 2 2
2 3 Line 3 3
3 4 None 4
>>>
>>> # populate with 1 record with NULL short field, check GeoAccessor.from_table results
>>> with arcpy.da.InsertCursor(tbl, ["TXT_FLD", "SHORT_FLD"]) as cur:
... res = cur.insertRow(next(recs))
...
>>> pd.DataFrame.spatial.from_table(tbl, skip_nulls=False)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\features\geo\_accessor.py", line 2422, in from_table
return from_table(filename, **kwargs)
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\features\geo\_io\fileops.py", line 257, in from_table
null_value=null_value))
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'
>>> |
UPDATE: The root cause appears to be having a field in the table of data type SHORT. If I remove any fields with that data type, everything works as expected. If I add a SHORT field to the table, it generates empty data frame.
The text was updated successfully, but these errors were encountered: