<?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 Calculate Field in ArcGIS Pro 2.7 Python Stand-Alone Fails in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/calculate-field-in-arcgis-pro-2-7-python-stand/m-p/1131352#M63420</link>
    <description>&lt;P&gt;I am trying to execute a calculate field in arcpy from ArcGIS Pro 2.7.&amp;nbsp; Here is the relevant code.&lt;/P&gt;&lt;P&gt;#a confirmed existing shapefile ....&lt;/P&gt;&lt;P&gt;out_fc = r'C:\GIS\telemetrytags\individual_fish_individual_days\112_2019-04-12.shp'&lt;/P&gt;&lt;P&gt;# a confirmed and working add field....&lt;/P&gt;&lt;P&gt;arcpy.AddField_management(out_fc, 'TagID', "SHORT")&lt;/P&gt;&lt;P&gt;#The existing field name...&lt;BR /&gt;tagid = "TagID"&lt;/P&gt;&lt;P&gt;#The value to populate TagID with...in this case the value of tag is a float (with a value of 112.0) before I #convert it to an int and then string.&lt;BR /&gt;value = str(int(tag))&lt;/P&gt;&lt;P&gt;#code fails here with the message below.&lt;BR /&gt;arcpy.CalculateFields_management(out_fc, tagid, value, "PYTHON3")&lt;/P&gt;&lt;P&gt;Error Info:&lt;BR /&gt;Failed to execute. Parameters are not valid.&lt;BR /&gt;ERROR 000800: The value is not a member of Python 3 | Arcade.&lt;BR /&gt;ERROR 000728: Field 112 does not exist within table&lt;BR /&gt;Failed to execute (CalculateFields).&lt;/P&gt;&lt;P&gt;112 is the value I am trying to populate field TagID with and not the field name so I do not understand what is up with that error.&lt;/P&gt;&lt;P&gt;Another oddity - when I add my shapefile to ArcGIS pro and check the TagID field it returns that the field is a type Long with is not what I am doing with the calculate field.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Why is this 'the most simple of calculations' failing in arcpy for ArcGIS Pro 2.7&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 06 Jan 2022 19:35:01 GMT</pubDate>
    <dc:creator>GerryGabrisch</dc:creator>
    <dc:date>2022-01-06T19:35:01Z</dc:date>
    <item>
      <title>Calculate Field in ArcGIS Pro 2.7 Python Stand-Alone Fails</title>
      <link>https://community.esri.com/t5/python-questions/calculate-field-in-arcgis-pro-2-7-python-stand/m-p/1131352#M63420</link>
      <description>&lt;P&gt;I am trying to execute a calculate field in arcpy from ArcGIS Pro 2.7.&amp;nbsp; Here is the relevant code.&lt;/P&gt;&lt;P&gt;#a confirmed existing shapefile ....&lt;/P&gt;&lt;P&gt;out_fc = r'C:\GIS\telemetrytags\individual_fish_individual_days\112_2019-04-12.shp'&lt;/P&gt;&lt;P&gt;# a confirmed and working add field....&lt;/P&gt;&lt;P&gt;arcpy.AddField_management(out_fc, 'TagID', "SHORT")&lt;/P&gt;&lt;P&gt;#The existing field name...&lt;BR /&gt;tagid = "TagID"&lt;/P&gt;&lt;P&gt;#The value to populate TagID with...in this case the value of tag is a float (with a value of 112.0) before I #convert it to an int and then string.&lt;BR /&gt;value = str(int(tag))&lt;/P&gt;&lt;P&gt;#code fails here with the message below.&lt;BR /&gt;arcpy.CalculateFields_management(out_fc, tagid, value, "PYTHON3")&lt;/P&gt;&lt;P&gt;Error Info:&lt;BR /&gt;Failed to execute. Parameters are not valid.&lt;BR /&gt;ERROR 000800: The value is not a member of Python 3 | Arcade.&lt;BR /&gt;ERROR 000728: Field 112 does not exist within table&lt;BR /&gt;Failed to execute (CalculateFields).&lt;/P&gt;&lt;P&gt;112 is the value I am trying to populate field TagID with and not the field name so I do not understand what is up with that error.&lt;/P&gt;&lt;P&gt;Another oddity - when I add my shapefile to ArcGIS pro and check the TagID field it returns that the field is a type Long with is not what I am doing with the calculate field.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Why is this 'the most simple of calculations' failing in arcpy for ArcGIS Pro 2.7&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jan 2022 19:35:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculate-field-in-arcgis-pro-2-7-python-stand/m-p/1131352#M63420</guid>
      <dc:creator>GerryGabrisch</dc:creator>
      <dc:date>2022-01-06T19:35:01Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Field in ArcGIS Pro 2.7 Python Stand-Alone Fails</title>
      <link>https://community.esri.com/t5/python-questions/calculate-field-in-arcgis-pro-2-7-python-stand/m-p/1131361#M63422</link>
      <description>&lt;P data-unlink="true"&gt;You're trying to use the syntax for &lt;A href="https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/calculate-field.htm" target="_self"&gt;Calculate Field&lt;/A&gt; with the&amp;nbsp;&lt;A href="https://pro.arcgis.com/en/pro-app/2.8/tool-reference/data-management/calculate-fields.htm" target="_self"&gt;Calculate Field&lt;STRONG&gt;s&lt;/STRONG&gt;&lt;/A&gt; tool. The syntax for Calculate Field&lt;STRONG&gt;s&lt;/STRONG&gt; is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;arcpy.CalculateFields_management(in_table, expression_type, fields, {code_block}, ...)
#Or
arcpy.management.CalculateFields(in_table, expression_type, fields, {code_block}, ...)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The syntax for Calculate Field is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;arcpy.management.CalculateField(in_table, field, expression, {expression_type}, {code_block}, etc...)
#Or
arcpy.CalculateField_management(in_table, field, expression, {expression_type}, {code_block}, etc...)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P data-unlink="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;P data-unlink="true"&gt;&lt;SPAN&gt;As you're only calculating a single field, just change to using the Calculate Field tool:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;arcpy.CalculateField_management(out_fc, tagid, value, "PYTHON3")
#Or
arcpy.management.CalculateField(out_fc, tagid, value, "PYTHON3")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P data-unlink="true"&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jan 2022 20:06:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculate-field-in-arcgis-pro-2-7-python-stand/m-p/1131361#M63422</guid>
      <dc:creator>Luke_Pinner</dc:creator>
      <dc:date>2022-01-06T20:06:05Z</dc:date>
    </item>
  </channel>
</rss>

