Hi Everyone
For some reason, the column name of the pd.DataFrame.spatial is changed after I saved it to a file.
Here is before I save it to a file:
Here is after I save it to a file
Here is the code
print(cat_riv_select.columns)
cat_riv_select.spatial.to_featureclass(location=Outputfilename_cat_riv)
print(cat_ply_select.columns)
Is there any option I did not include?
My ArcGIS pro version is 2.7.
Thanks
Ming
Solved! Go to Solution.
It seems to be working when I test it. What's the "cat_ply_select.columns" object in your code? If you're instantiating it prior to the to_featureclass function, you'll need to re-create it from the newly-exported file.
Try reading the new file with pandas.DataFrame.spatial.from_featureclass() and see if the column name persists.
In the to_featureclass method, there is an optional Boolean parameter santize_columns that defaults to True. Set this parameter to False to keep your column names as you have them written.
If you look at the docs for the sanitize_column_names method itself, you can see that the default option is "snake_case".
Hi Josh
I tried the following commands:
print(cat_riv_select.columns)
cat_riv_select.spatial.to_featureclass(location=Outputfilename_cat_riv,overwrite=True,sanitize_columns=0)
print(cat_ply_select.columns)
But still get the same outputs....
It seems to be working when I test it. What's the "cat_ply_select.columns" object in your code? If you're instantiating it prior to the to_featureclass function, you'll need to re-create it from the newly-exported file.
Try reading the new file with pandas.DataFrame.spatial.from_featureclass() and see if the column name persists.
I double test in the ArcGIS notebook, seems it is work there, I guess I got something wrong in my code. Many thanks for your help
Ming
I got an error: "to_featureclass() got an unexpected keyword argument 'santize_columns'"
by this:
cat_riv_select.spatial.to_featureclass(location=Outputfilename_cat_riv,santize_columns=False)
Hi,
Did this ever get resolved? I get the same error now.
Thanks Gert