<?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 Pandas dataframe to Esri table fails after ArcGIS Pro update to 3.2 in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/pandas-dataframe-to-esri-table-fails-after-arcgis/m-p/1359349#M76208</link>
    <description>&lt;P&gt;I have a script that worked perfectly last week...before I upgraded from ArcGIS Pro 2.9.5 to 3.2 (see below script).&lt;/P&gt;&lt;P&gt;The script is something that I recreated using help from &lt;A href="https://community.esri.com/t5/arcgis-online-questions/creating-a-feature-layer-from-an-api/td-p/1097259" target="_blank" rel="noopener"&gt;this post&amp;nbsp;&amp;nbsp;&lt;/A&gt;(thank you&amp;nbsp;@jcarlson). The script is run within the python window in Pro.&lt;/P&gt;&lt;P&gt;When I re-ran this script this week, after updating to Pro 3.2, the script no longer works. I was able to test it on a workstation that was still on 2.9.5, and it works! So that is pretty clear to me that something has changed from the python/panda libraries between 2.9.5 and 3.2.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The error I am getting happens on the last line of the script when I try to write the dataframe to a table. Yes, I know the table does not have any geometry, but this worked in the past and created a fgdb table perfectly. The error I get is: "TypeError: 'field_names' must be string or non empty list or tuple of strings"&lt;/P&gt;&lt;P&gt;I am a self-proclaimed hack at python/pandas, so any help is greatly appreciated to get this up and running again.&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/363906"&gt;@jcarlson&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/1066"&gt;@DanPatterson_Retired&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
arcpy.env.workspace = "N:\ArcShared\Planning\CompPlanUpdate_2025\Data\BellinghamProfile\BhamDataBook_2022.gdb" 
arcpy.env.overwriteOutput = True

# Import modules
from arcgis import GIS
import pandas as pd
import requests
import json

#-------------------------------------------------------------------------------------

#-------------------------------------------------------------------------------------
#TOTAL POPULATION, SEX, AGE &amp;amp; RACE data for Bellingham City

# Submit request to API
response = requests.get('https://api.census.gov/data/2022/acs/acs5/profile?get=NAME,DP05_0001E,DP05_0002E,DP05_0003E,DP05_0005E,DP05_0006E,DP05_0007E,DP05_0008E,DP05_0009E,DP05_0010E,DP05_0011E,DP05_0012E,DP05_0013E,DP05_0014E,DP05_0015E,DP05_0016E,DP05_0017E,DP05_0018E,DP05_0073E,DP05_0079E,DP05_0080E,DP05_0081E,DP05_0082E,DP05_0083E,DP05_0084E,DP05_0085E,DP05_0019E,DP05_0024E&amp;amp;for=place:05280&amp;amp;in=state:53')


# Read response as JSON into dataframe
# First row is column names, skipped for data import
df = pd.DataFrame(response.json()[1:])

# Apply column names from first row
cols = response.json()[0]
column_dict = {}
for c in cols:
    column_dict.update({cols.index(c):c})
    
df.rename(columns=column_dict, inplace=True)
df = df.astype({"NAME": str, "DP05_0001E": int, "DP05_0002E": int, "DP05_0003E": int, "DP05_0005E": int, "DP05_0006E": int, "DP05_0007E": int, "DP05_0008E": int, "DP05_0009E": int, "DP05_0010E": int,	"DP05_0011E": int, "DP05_0012E": int, "DP05_0013E": int, "DP05_0014E": int, "DP05_0015E": int, "DP05_0016E": int, "DP05_0017E": int, "DP05_0018E": float,"DP05_0073E": int,"DP05_0079E": int,"DP05_0080E": int,"DP05_0081E": int,"DP05_0082E": int,"DP05_0083E": int,"DP05_0084E": int,"DP05_0085E": int,"DP05_0019E":int,"DP05_0024E":int})

        
# Export to layer
processed_table = df.spatial.to_table('DP05_Pop_Age_Sex_Race')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 11 Dec 2023 20:33:10 GMT</pubDate>
    <dc:creator>KateNewell1</dc:creator>
    <dc:date>2023-12-11T20:33:10Z</dc:date>
    <item>
      <title>Pandas dataframe to Esri table fails after ArcGIS Pro update to 3.2</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/pandas-dataframe-to-esri-table-fails-after-arcgis/m-p/1359349#M76208</link>
      <description>&lt;P&gt;I have a script that worked perfectly last week...before I upgraded from ArcGIS Pro 2.9.5 to 3.2 (see below script).&lt;/P&gt;&lt;P&gt;The script is something that I recreated using help from &lt;A href="https://community.esri.com/t5/arcgis-online-questions/creating-a-feature-layer-from-an-api/td-p/1097259" target="_blank" rel="noopener"&gt;this post&amp;nbsp;&amp;nbsp;&lt;/A&gt;(thank you&amp;nbsp;@jcarlson). The script is run within the python window in Pro.&lt;/P&gt;&lt;P&gt;When I re-ran this script this week, after updating to Pro 3.2, the script no longer works. I was able to test it on a workstation that was still on 2.9.5, and it works! So that is pretty clear to me that something has changed from the python/panda libraries between 2.9.5 and 3.2.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The error I am getting happens on the last line of the script when I try to write the dataframe to a table. Yes, I know the table does not have any geometry, but this worked in the past and created a fgdb table perfectly. The error I get is: "TypeError: 'field_names' must be string or non empty list or tuple of strings"&lt;/P&gt;&lt;P&gt;I am a self-proclaimed hack at python/pandas, so any help is greatly appreciated to get this up and running again.&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/363906"&gt;@jcarlson&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/1066"&gt;@DanPatterson_Retired&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
arcpy.env.workspace = "N:\ArcShared\Planning\CompPlanUpdate_2025\Data\BellinghamProfile\BhamDataBook_2022.gdb" 
arcpy.env.overwriteOutput = True

# Import modules
from arcgis import GIS
import pandas as pd
import requests
import json

#-------------------------------------------------------------------------------------

#-------------------------------------------------------------------------------------
#TOTAL POPULATION, SEX, AGE &amp;amp; RACE data for Bellingham City

# Submit request to API
response = requests.get('https://api.census.gov/data/2022/acs/acs5/profile?get=NAME,DP05_0001E,DP05_0002E,DP05_0003E,DP05_0005E,DP05_0006E,DP05_0007E,DP05_0008E,DP05_0009E,DP05_0010E,DP05_0011E,DP05_0012E,DP05_0013E,DP05_0014E,DP05_0015E,DP05_0016E,DP05_0017E,DP05_0018E,DP05_0073E,DP05_0079E,DP05_0080E,DP05_0081E,DP05_0082E,DP05_0083E,DP05_0084E,DP05_0085E,DP05_0019E,DP05_0024E&amp;amp;for=place:05280&amp;amp;in=state:53')


# Read response as JSON into dataframe
# First row is column names, skipped for data import
df = pd.DataFrame(response.json()[1:])

# Apply column names from first row
cols = response.json()[0]
column_dict = {}
for c in cols:
    column_dict.update({cols.index(c):c})
    
df.rename(columns=column_dict, inplace=True)
df = df.astype({"NAME": str, "DP05_0001E": int, "DP05_0002E": int, "DP05_0003E": int, "DP05_0005E": int, "DP05_0006E": int, "DP05_0007E": int, "DP05_0008E": int, "DP05_0009E": int, "DP05_0010E": int,	"DP05_0011E": int, "DP05_0012E": int, "DP05_0013E": int, "DP05_0014E": int, "DP05_0015E": int, "DP05_0016E": int, "DP05_0017E": int, "DP05_0018E": float,"DP05_0073E": int,"DP05_0079E": int,"DP05_0080E": int,"DP05_0081E": int,"DP05_0082E": int,"DP05_0083E": int,"DP05_0084E": int,"DP05_0085E": int,"DP05_0019E":int,"DP05_0024E":int})

        
# Export to layer
processed_table = df.spatial.to_table('DP05_Pop_Age_Sex_Race')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Dec 2023 20:33:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/pandas-dataframe-to-esri-table-fails-after-arcgis/m-p/1359349#M76208</guid>
      <dc:creator>KateNewell1</dc:creator>
      <dc:date>2023-12-11T20:33:10Z</dc:date>
    </item>
    <item>
      <title>Re: Pandas dataframe to Esri table fails after ArcGIS Pro update to 3.2</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/pandas-dataframe-to-esri-table-fails-after-arcgis/m-p/1359369#M76210</link>
      <description>&lt;P&gt;Odd. "field_names" isn't a parameter you get to define in that function...&lt;/P&gt;&lt;P&gt;If you have a script that you need to work consistently, it's a good idea to keep a stable Python env for it. Pro has a built-in environment manager, or honestly you could just install &lt;A href="https://mamba.readthedocs.io/en/latest/index.html" target="_blank"&gt;Mamba&lt;/A&gt; to manage your envs outside of Pro. If you prefer a full GUI setup, you can check out &lt;A href="https://docs.anaconda.com/free/navigator/" target="_blank"&gt;Anaconda Navigator&lt;/A&gt;, too.&lt;/P&gt;&lt;P&gt;It doesn't look like your script actually needs arcpy at all, so you really don't need to run it from Pro. You could invoke the script from the terminal, a Jupyter notebook, or wherever else.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Dec 2023 20:54:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/pandas-dataframe-to-esri-table-fails-after-arcgis/m-p/1359369#M76210</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2023-12-11T20:54:28Z</dc:date>
    </item>
    <item>
      <title>Re: Pandas dataframe to Esri table fails after ArcGIS Pro update to 3.2</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/pandas-dataframe-to-esri-table-fails-after-arcgis/m-p/1359394#M76211</link>
      <description>&lt;P&gt;you might want to raise an issue on&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/Esri/arcgis-python-api" target="_blank"&gt;Esri/arcgis-python-api: Documentation and samples for ArcGIS API for Python (github.com)&lt;/A&gt;&lt;/P&gt;&lt;P&gt;since the issue isn't arcpy but the arcgis and pandas modules were updated during the 3.2 migration&lt;/P&gt;</description>
      <pubDate>Mon, 11 Dec 2023 21:31:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/pandas-dataframe-to-esri-table-fails-after-arcgis/m-p/1359394#M76211</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2023-12-11T21:31:50Z</dc:date>
    </item>
    <item>
      <title>Re: Pandas dataframe to Esri table fails after ArcGIS Pro update to 3.2</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/pandas-dataframe-to-esri-table-fails-after-arcgis/m-p/1360548#M76345</link>
      <description>&lt;P&gt;Posted this as an issue on the ArcGIS API for Python GitHub site. Recommended change was&amp;nbsp;&lt;SPAN&gt;going from&amp;nbsp;&lt;/SPAN&gt;processed_table = df.spatial.to_table('DP05_Pop_Age_Sex_Race')&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;to&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;processed_table = df.spatial.to_table(os.path.join(arcpy.env.workspace, 'DP05_Pop_Age_Sex_Race'))&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;This resulted in the "to_table" functioning again, but all the field names were "sanitized", so needed to set that parameter to False:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;processed_table = df.spatial.to_table(os.path.join(arcpy.env.workspace, 'DP05_Pop_Age_Sex_Race',),overwrite=True, sanitize_columns=False)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/python/api-reference/arcgis.features.toc.html#arcgis.features.GeoAccessor.to_featureclass" target="_blank" rel="noopener"&gt;arcgis.features module | ArcGIS API for Python&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Dec 2023 19:43:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/pandas-dataframe-to-esri-table-fails-after-arcgis/m-p/1360548#M76345</guid>
      <dc:creator>KateNewell1</dc:creator>
      <dc:date>2023-12-13T19:43:40Z</dc:date>
    </item>
  </channel>
</rss>

