Hi All,
I'm trying to do the following:
However, I get the error "SystemError: <da.funcInfo object at 0x0000029FA43C52A0> returned NULL without setting an error".
I googled the error and the only hits I got implied the issue has something to do with making a C extension. Do any of you have any insights on this?
Here's the full code for context:
out_fc_path = 'I:\\Projects\\Darren\\EmpInventory\\EmploymentInventory.gdb\\testrecs9581720210407_1435'
sdft = GeoAccessor.from_xy(master_df, fld_lat, fld_lon) # no issues here!
sdft.spatial.to_featureclass(location=out_fc_path)
Traceback (most recent call last):
File "<ipython-input-29-2e5a93021399>", line 1, in <module>
sdft.spatial.to_featureclass(location=out_fc_path)
File "C:\Users\dconly\AppData\Local\ESRI\conda\envs\arcgispro-py3-dcmar21\lib\site-packages\arcgis\features\geo\_accessor.py", line 2122, in to_featureclass
has_m=has_m)
File "C:\Users\dconly\AppData\Local\ESRI\conda\envs\arcgispro-py3-dcmar21\lib\site-packages\arcgis\features\geo\_io\fileops.py", line 708, in to_featureclass
arcpy.da.ExtendTable(fc, oidfld, array, join_dummy, append_only=False)
SystemError: <da.funcInfo object at 0x0000029FA43C52A0> returned NULL without setting an error
Solved! Go to Solution.
I found the solution!
In trying to find a workaround, I discovered that you cannot export a spatial dataframe to a file or feature class if it contains categorical data types. To fix this, you must convert all categorical data types to string data type.
Example: if you have a column 'X' that is categorical, you must first convert to string data type by doing the following:
df['X'] = df['X'].astype('str')
I'm happy to have resolved this, and hope my solution is informative to others.
Cheers,
I found the solution!
In trying to find a workaround, I discovered that you cannot export a spatial dataframe to a file or feature class if it contains categorical data types. To fix this, you must convert all categorical data types to string data type.
Example: if you have a column 'X' that is categorical, you must first convert to string data type by doing the following:
df['X'] = df['X'].astype('str')
I'm happy to have resolved this, and hope my solution is informative to others.
Cheers,
Darren, this led me in the right direction to solve similar issue. In my case I had a number of seemingly invalid data types, so this small function fixed it.
Cheers, John
def convert_dtypes_arcgis(df):
# Convert dataframe dtypes which are not compatible with ArcGIS
# Use builtin Pandas dtype conversion
df = df.convert_dtypes(infer_objects=True)
# Then str convert any remaining special object/category fields
for col in df.columns:
# print(col, '/', df[col].dtype)
if df[col].dtype == 'object' or df[col].dtype == 'category':
df[col] = df[col].astype('str')
# Return modified df
return df
Thanks for posting the solution
@MinbinJiang is this going to become a built-in for the API? I recently ran into this issue and am glad there's a workaround, but this seems to be a pretty significant defect.