Skip to content

Inconsistent conversion of dataframe to table using GeoAccessor spatial.to_table() #2410

@cybersea

Description

@cybersea

I am using GeoAccessor spatial.to_table() method to convert standard pandas dataframes to geodatabase tables. This previously worked (ArcPro v.2.9) as long as I converted incompatible fields as described in this post: https://community.esri.com/t5/arcgis-api-for-python-questions/system-error-when-exporting-spatially-enabled/td-p/1044880

I'm now on ArcPro v.3.3, and I'm having inconsistent results. Some dataframes are converting to geodatabase tables and some are not, even though the fields causing issues are in both the successfully converted dataframes and the ones that are failing.

Below is a sample traceback -- with the TypeError at the bottom

Traceback (most recent call last):
  File "d:\abai490\tlt\scripts\tlt_parcel_stats_debug.py", line 696, in <module>
    main(parcel_fc, parcelid_field,  yields_npv_tbl, yields_blv_tbl, slvmgt_tbl, stumpage_tbl, discount_rates_tbl, out_dir)
  File "d:\abai490\tlt\scripts\tlt_parcel_stats_debug.py", line 678, in main
    export_npvblv(pcl_df_list, riu_df_list, output_geodatabase, out_dir, timestamp, parcel_file_pfx)
  File "d:\abai490\tlt\scripts\tlt_parcel_stats_debug.py", line 588, in export_npvblv
    export_table(parcel_npvblv_df, out_gdb, f'{file_pfx}_npv_blv')
  File "d:\abai490\tlt\scripts\tlt_parcel_stats_debug.py", line 378, in export_table
    mod_df.spatial.to_table(os.path.join(gdb, out_table))
  File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\arcgis\features\geo\_accessor.py", line 2751, in to_table
    table = run_and_hide(
            ^^^^^^^^^^^^^
  File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\arcgis\features\geo\_tools\_utils.py", line 30, in run_and_hide
    raise err
  File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\arcgis\features\geo\_tools\_utils.py", line 23, in run_and_hide
    res = fn(**kwargs)
          ^^^^^^^^^^^^
  File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\arcgis\features\geo\_io\fileops.py", line 617, in to_table
    arcpy.da.ExtendTable(fc, oidfld, array, join_dummy, append_only=False)
TypeError: cannot add field: 'parcel_id'

I tested this with a standard pandas data frame and a SEDF (with dummy x/y), in the method call and both throw the error. mod_df.spatial.to_table(os.path.join(gdb, out_table))

I'm not sure if this is a bug, or a request for assistance. I am definitely puzzled by the fact that it worked previously and now it works inconsistently. Thanks for any suggestions for resolving this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions