<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Convert multiple feature classes to dataframes using GeoAccessor in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/convert-multiple-feature-classes-to-dataframes/m-p/1210890#M7728</link>
    <description>&lt;P&gt;Ah, yes! Many thanks!&lt;/P&gt;</description>
    <pubDate>Thu, 08 Sep 2022 17:56:51 GMT</pubDate>
    <dc:creator>PenelopeMitchell</dc:creator>
    <dc:date>2022-09-08T17:56:51Z</dc:date>
    <item>
      <title>Convert multiple feature classes to dataframes using GeoAccessor</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/convert-multiple-feature-classes-to-dataframes/m-p/1210549#M7719</link>
      <description>&lt;P&gt;I wrote a function that should read in multiple feature classes and return pandas dataframes. Here is the code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;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&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;When I run the function as follows:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;DF_from_Ftr(CHList)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;One dataframe is shown in the print screen.&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;DF_from_Ftr(CHList)[1]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What might I be doing wrong here?&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Wed, 07 Sep 2022 20:45:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/convert-multiple-feature-classes-to-dataframes/m-p/1210549#M7719</guid>
      <dc:creator>PenelopeMitchell</dc:creator>
      <dc:date>2022-09-07T20:45:29Z</dc:date>
    </item>
    <item>
      <title>Re: Convert multiple feature classes to dataframes using GeoAccessor</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/convert-multiple-feature-classes-to-dataframes/m-p/1210571#M7720</link>
      <description>&lt;P&gt;If CHList is a list, then you need to index it inside your function:&lt;/P&gt;&lt;PRE&gt;DF_from_Ftr(CHList[1])&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 Sep 2022 21:13:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/convert-multiple-feature-classes-to-dataframes/m-p/1210571#M7720</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2022-09-07T21:13:46Z</dc:date>
    </item>
    <item>
      <title>Re: Convert multiple feature classes to dataframes using GeoAccessor</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/convert-multiple-feature-classes-to-dataframes/m-p/1210585#M7721</link>
      <description>&lt;P&gt;Thanks for your response-- reading that&amp;nbsp; I would think that would perform the function on the second item in CHList--but the output is an OSError: "C" does not exist.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Sep 2022 21:52:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/convert-multiple-feature-classes-to-dataframes/m-p/1210585#M7721</guid>
      <dc:creator>PenelopeMitchell</dc:creator>
      <dc:date>2022-09-07T21:52:34Z</dc:date>
    </item>
    <item>
      <title>Re: Convert multiple feature classes to dataframes using GeoAccessor</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/convert-multiple-feature-classes-to-dataframes/m-p/1210678#M7723</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/127793"&gt;@PenelopeMitchell&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your function is returning one sdf. The last one from the input. Create an empty list in the function and append in each sdf, then return the list, as below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def DF_from_Ftr(in_features):
    sdf_list = []
    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)
        sdf_list.append(sdf)
    return sdf_list&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Call your function&lt;/P&gt;&lt;LI-CODE lang="python"&gt;sdf_list = DF_from_Ftr(CHList)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then access the elements of the list with indexing&lt;/P&gt;&lt;LI-CODE lang="python"&gt;sdf_1 = sdf_list[0]
sdf_2 = sdf_list[1]
sdf_3 = sdf_list[2]
## and so on&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 08 Sep 2022 08:08:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/convert-multiple-feature-classes-to-dataframes/m-p/1210678#M7723</guid>
      <dc:creator>Clubdebambos</dc:creator>
      <dc:date>2022-09-08T08:08:25Z</dc:date>
    </item>
    <item>
      <title>Re: Convert multiple feature classes to dataframes using GeoAccessor</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/convert-multiple-feature-classes-to-dataframes/m-p/1210890#M7728</link>
      <description>&lt;P&gt;Ah, yes! Many thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 08 Sep 2022 17:56:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/convert-multiple-feature-classes-to-dataframes/m-p/1210890#M7728</guid>
      <dc:creator>PenelopeMitchell</dc:creator>
      <dc:date>2022-09-08T17:56:51Z</dc:date>
    </item>
  </channel>
</rss>

