I wrote a function that should read in multiple feature classes and return pandas dataframes. Here is the code:
import pandas as pd
from arcgis.features import GeoAccessor, GeoSeriesAccessor
CHList=arcpy.ListFeatureClasses('*CH') # list feature classes from ArcGIS Pro and assign to variable
def DF_from_Ftr(in_features):
for feature in in_features:
sdf = pd.DataFrame.spatial.from_featureclass(feature) #use geoaccessor to convert ftr to df
sdf.drop(['SHAPE'], axis=1, inplace=True)
return sdf
When I run the function as follows:
DF_from_Ftr(CHList)
One dataframe is shown in the print screen.
When i try to access the other dataframes (there should be 30 of them) using indexing (shown in code below), I get a key error for whatever index number I use indicating that dataframe object isn't there.
DF_from_Ftr(CHList)[1]
What might I be doing wrong here?
Thank you!