<?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: Python Toolbox: carry out multiple tasks in the source code def execute() function in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/python-toolbox-carry-out-multiple-tasks-in-the/m-p/1700166#M103055</link>
    <description>&lt;P&gt;This line is the problem:&lt;BR /&gt;&lt;BR /&gt;df = DataFrame(columns=['Shape X', 'Shape Y'])&lt;BR /&gt;&lt;BR /&gt;It replaces df (the CSV you read) with a new a new DataFrame that only has those two columns.&lt;BR /&gt;&lt;BR /&gt;Try these changes:&amp;nbsp;&lt;/P&gt;&lt;P&gt;# Pandas section ------&lt;/P&gt;&lt;P&gt;df = pd.read_csv(parameters[1].valueAsText)&lt;/P&gt;&lt;P&gt;# remove spaces from ALL column names&lt;/P&gt;&lt;P&gt;df.columns = df.columns.str.replace(" ", "", regex=False)&lt;/P&gt;&lt;P&gt;# write back to the same output CSV&lt;/P&gt;&lt;P&gt;df.to_csv(parameters[1].valueAsText, index=False)&lt;/P&gt;</description>
    <pubDate>Tue, 05 May 2026 17:01:41 GMT</pubDate>
    <dc:creator>Robert_LeClair</dc:creator>
    <dc:date>2026-05-05T17:01:41Z</dc:date>
    <item>
      <title>Python Toolbox: carry out multiple tasks in the source code def execute() function</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/python-toolbox-carry-out-multiple-tasks-in-the/m-p/1700144#M103054</link>
      <description>&lt;P&gt;This code is in the def execute() function of a python toolbox.&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;A table is geocoded.&lt;/LI&gt;&lt;LI&gt;Then I want to remove&amp;nbsp;spaces in two column names with the same out file parameter.&amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;The tool runs without error, and the file is saved to a directory. But, the spaces are not removed. I'm thinking this is because the arcpy.geocoding.GeocodeFile() function hasn't been returned yet. Can anyone clue me in?&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def execute(self, parameters, messages):
        """The source code of the tool."""
        import arcpy
        import os
        import pandas as pd
        
        outfile = parameters[1].valueAsText
        outloc = os.path.dirname(outfile)
        outname = os.path.basename(outfile)
   
        arcpy.geocoding.GeocodeFile(
        in_table=parameters[0].valueAsText,
        locator="https://filepathto/GeocodeServer/Locators/Locator_AddPts",
        address_fields="'Address or Place' ADDRESS VISIBLE NONE;Address2 &amp;lt;None&amp;gt; VISIBLE NONE;Address3 &amp;lt;None&amp;gt; VISIBLE NONE;Neighborhood &amp;lt;None&amp;gt; VISIBLE NONE;City CITY VISIBLE NONE;County COUNTY VISIBLE NONE;State STATE VISIBLE NONE;ZIP ZIPCODE VISIBLE NONE;ZIP4 &amp;lt;None&amp;gt; VISIBLE NONE;Country &amp;lt;None&amp;gt; VISIBLE NONE",
        output_type="CSV",
        output_location=outloc,
        output_name=outname,
        country=None,
        location_type="ROUTING_LOCATION",
        category=None,
        output_fields="LOCATION_ONLY"
        )
        
        # Pandas section ------
        df = pd.read_csv(parameters[1].valueAsText)

        #replace white space in column name with no white space
        df = pd.DataFrame(columns=['Shape X','Shape Y'])
        df.columns = [col.replace(' ','') if isinstance(col, str) else col for col in df.columns]
        df.to_csv(os.path.join(parameters[1].valueAsText))
        
        return&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried putting the pandas section in this section of the python toolbox, but it produces an error and I'm not even sure what goes here.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;   def postExecute(self, parameters):
        """This method takes place after outputs are processed and
        added to the display."""

        return&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 May 2026 16:23:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/python-toolbox-carry-out-multiple-tasks-in-the/m-p/1700144#M103054</guid>
      <dc:creator>JaredPilbeam2</dc:creator>
      <dc:date>2026-05-05T16:23:20Z</dc:date>
    </item>
    <item>
      <title>Re: Python Toolbox: carry out multiple tasks in the source code def execute() function</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/python-toolbox-carry-out-multiple-tasks-in-the/m-p/1700166#M103055</link>
      <description>&lt;P&gt;This line is the problem:&lt;BR /&gt;&lt;BR /&gt;df = DataFrame(columns=['Shape X', 'Shape Y'])&lt;BR /&gt;&lt;BR /&gt;It replaces df (the CSV you read) with a new a new DataFrame that only has those two columns.&lt;BR /&gt;&lt;BR /&gt;Try these changes:&amp;nbsp;&lt;/P&gt;&lt;P&gt;# Pandas section ------&lt;/P&gt;&lt;P&gt;df = pd.read_csv(parameters[1].valueAsText)&lt;/P&gt;&lt;P&gt;# remove spaces from ALL column names&lt;/P&gt;&lt;P&gt;df.columns = df.columns.str.replace(" ", "", regex=False)&lt;/P&gt;&lt;P&gt;# write back to the same output CSV&lt;/P&gt;&lt;P&gt;df.to_csv(parameters[1].valueAsText, index=False)&lt;/P&gt;</description>
      <pubDate>Tue, 05 May 2026 17:01:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/python-toolbox-carry-out-multiple-tasks-in-the/m-p/1700166#M103055</guid>
      <dc:creator>Robert_LeClair</dc:creator>
      <dc:date>2026-05-05T17:01:41Z</dc:date>
    </item>
  </channel>
</rss>

