Last active
April 19, 2021 20:50
-
-
Save d-wasserman/5e3c1e7151ac8c6323bfb50ab525264f to your computer and use it in GitHub Desktop.
Returns pandas dataframe with all col names renamed to be valid ArcGIS table names.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import arcpy | |
def validate_df_names(dataframe,output_feature_class_workspace): | |
"""Returns pandas dataframe with all col names renamed to be valid arcgis table names.""" | |
new_name_list=[] | |
old_names=dataframe.columns.names | |
for name in old_names: | |
new_name=arcpy.ValidateFieldName(name,output_feature_class_workspace) | |
new_name_list.append(new_name) | |
rename_dict={i:j for i,j in zip(old_names,new_name_list)} | |
dataframe.rename(index = str,columns=rename_dict) | |
return dataframe |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment