<?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: df.spatial.to_table reverting column names in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/df-spatial-to-table-reverting-column-names/m-p/1624093#M74383</link>
    <description>&lt;P&gt;This rebuilds the schema, ignoring modified columns names. cleaned_up_values_df.spatial.to_table(r'memory/out_table')&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;try something like this, untested.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;import arcpy
import numpy as np

# Reset index if needed 
df_export = cleaned_up_values_df.reset_index()

# Convert to NumPy structured array with explicit uppercase field names
dtype = [(str(col.upper()), 'U255') for col in df_export.columns]  # 'U255' = Unicode string (max 255 chars)
records = np.array([tuple(row) for row in df_export.values], dtype=dtype)

# Export to in-memory table
arcpy.da.NumPyArrayToTable(records, r"memory\out_table")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 16 Jun 2025 23:13:34 GMT</pubDate>
    <dc:creator>TonyAlmeida</dc:creator>
    <dc:date>2025-06-16T23:13:34Z</dc:date>
    <item>
      <title>df.spatial.to_table reverting column names</title>
      <link>https://community.esri.com/t5/python-questions/df-spatial-to-table-reverting-column-names/m-p/1623958#M74380</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am importing a csv from an AWS S3 bucket into a pandas dataframe. I am using pandas to clean up the values and column names, mainly by converting all strings to upper case. The column names and values in the csv are in lower case, and that is not desired for us. The code below does a nice job of making everything upper case:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;df.columns = df.columns.str.upper()
for col in df.select_dtypes(include=['object']).columns:
    df[col] = df[col].str.upper()

cleaned_up_values_df = df.set_index('OBJECTID')&lt;/LI-CODE&gt;&lt;P&gt;However, the problem occurs when I use df.spatial.to_table to export the dataframe to a memory table format compatible with arcpy. All of the column names and values convert back to the original lower case formatting. This is the code I use:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;cleaned_up_values_df.spatial.to_table(r'memory/out_table')&lt;/LI-CODE&gt;&lt;P&gt;Am I missing a parameter with pandas? I'd prefer to not use arcpy to change the column names again since pandas makes it so easy. TIA.&lt;/P&gt;&lt;P&gt;Edit: I should also mention this script will run on a nightly schedule and will need to be able to overwrite the memory table each time.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jun 2025 17:47:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/df-spatial-to-table-reverting-column-names/m-p/1623958#M74380</guid>
      <dc:creator>B_NewGE</dc:creator>
      <dc:date>2025-06-17T17:47:49Z</dc:date>
    </item>
    <item>
      <title>Re: df.spatial.to_table reverting column names</title>
      <link>https://community.esri.com/t5/python-questions/df-spatial-to-table-reverting-column-names/m-p/1624007#M74381</link>
      <description>&lt;P&gt;BTW, including the sanitize_column='False' parameter did not fix the problem.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;cleaned_up_df.spatial.to_table(location=r'memory/ewt',sanitize_columns='False')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Jun 2025 22:04:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/df-spatial-to-table-reverting-column-names/m-p/1624007#M74381</guid>
      <dc:creator>B_NewGE</dc:creator>
      <dc:date>2025-06-16T22:04:13Z</dc:date>
    </item>
    <item>
      <title>Re: df.spatial.to_table reverting column names</title>
      <link>https://community.esri.com/t5/python-questions/df-spatial-to-table-reverting-column-names/m-p/1624093#M74383</link>
      <description>&lt;P&gt;This rebuilds the schema, ignoring modified columns names. cleaned_up_values_df.spatial.to_table(r'memory/out_table')&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;try something like this, untested.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;import arcpy
import numpy as np

# Reset index if needed 
df_export = cleaned_up_values_df.reset_index()

# Convert to NumPy structured array with explicit uppercase field names
dtype = [(str(col.upper()), 'U255') for col in df_export.columns]  # 'U255' = Unicode string (max 255 chars)
records = np.array([tuple(row) for row in df_export.values], dtype=dtype)

# Export to in-memory table
arcpy.da.NumPyArrayToTable(records, r"memory\out_table")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Jun 2025 23:13:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/df-spatial-to-table-reverting-column-names/m-p/1624093#M74383</guid>
      <dc:creator>TonyAlmeida</dc:creator>
      <dc:date>2025-06-16T23:13:34Z</dc:date>
    </item>
    <item>
      <title>Re: df.spatial.to_table reverting column names</title>
      <link>https://community.esri.com/t5/python-questions/df-spatial-to-table-reverting-column-names/m-p/1624408#M74389</link>
      <description>&lt;P&gt;just checking in practice are you using&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;sanitize_columns='False'&lt;/LI-CODE&gt;&lt;P&gt;because that is a string and it should be a Bool so like&lt;/P&gt;&lt;LI-CODE lang="python"&gt;sanitize_columns=False&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jun 2025 17:38:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/df-spatial-to-table-reverting-column-names/m-p/1624408#M74389</guid>
      <dc:creator>GISDepartmentMFM</dc:creator>
      <dc:date>2025-06-17T17:38:52Z</dc:date>
    </item>
    <item>
      <title>Re: df.spatial.to_table reverting column names</title>
      <link>https://community.esri.com/t5/python-questions/df-spatial-to-table-reverting-column-names/m-p/1624410#M74390</link>
      <description>&lt;P&gt;Thanks for this! This does work to maintain the modified column names, the only caveat is that I cannot overwrite the numpy array when running the script again. This script is going to run on a nightly schedule and I'll need to overwrite the memory table every time. Sorry, I should have mentioned that in my original post.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jun 2025 17:45:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/df-spatial-to-table-reverting-column-names/m-p/1624410#M74390</guid>
      <dc:creator>B_NewGE</dc:creator>
      <dc:date>2025-06-17T17:45:23Z</dc:date>
    </item>
    <item>
      <title>Re: df.spatial.to_table reverting column names</title>
      <link>https://community.esri.com/t5/python-questions/df-spatial-to-table-reverting-column-names/m-p/1624413#M74391</link>
      <description>&lt;P&gt;This was it, thank you! Of course it was something small, lol. I appreciate your help!&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jun 2025 17:50:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/df-spatial-to-table-reverting-column-names/m-p/1624413#M74391</guid>
      <dc:creator>B_NewGE</dc:creator>
      <dc:date>2025-06-17T17:50:23Z</dc:date>
    </item>
    <item>
      <title>Re: df.spatial.to_table reverting column names</title>
      <link>https://community.esri.com/t5/python-questions/df-spatial-to-table-reverting-column-names/m-p/1624415#M74392</link>
      <description>&lt;P&gt;I would add a&amp;nbsp;check to delete the existing in-memory.&lt;/P&gt;&lt;P&gt;Try this, untested&lt;/P&gt;&lt;PRE&gt;import arcpy
import numpy as np

# Reset index if needed
df_export = cleaned_up_values_df.reset_index()

# Convert to NumPy structured array with explicit uppercase field names
dtype = [(str(col.upper()), 'U255') for col in df_export.columns]  # 'U255' = Unicode string (max 255 chars)
records = np.array([tuple(row) for row in df_export.values], dtype=dtype)

# Define the in-memory table path
in_memory_table = r"memory\out_table"

# Check if the table exists and delete it if it does
if arcpy.Exists(in_memory_table):
    arcpy.management.Delete(in_memory_table)

# Export to in-memory table
arcpy.da.NumPyArrayToTable(records, in_memory_table)

# Verify the table was created
if arcpy.Exists(in_memory_table):
    print("Successfully created in-memory table")
else:
    print("Failed to create in-memory table")&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jun 2025 17:54:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/df-spatial-to-table-reverting-column-names/m-p/1624415#M74392</guid>
      <dc:creator>TonyAlmeida</dc:creator>
      <dc:date>2025-06-17T17:54:11Z</dc:date>
    </item>
  </channel>
</rss>

