<?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: Sum a list of fields in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/sum-a-list-of-fields/m-p/349722#M27427</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you are using PRO, see&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;A href="https://www.arcgis.com/home/item.html?id=7155956bfbcb4410b42419b4c5d079f5"&gt;Descriptive statistics for multiple fields&lt;/A&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A row sum of the selected fields is one of the outputs. &amp;nbsp;&lt;/P&gt;&lt;P&gt;If you don't want to use a pre-existing solution, then pull the code you need from it. &amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 08 May 2018 15:30:32 GMT</pubDate>
    <dc:creator>DanPatterson_Retired</dc:creator>
    <dc:date>2018-05-08T15:30:32Z</dc:date>
    <item>
      <title>Sum a list of fields</title>
      <link>https://community.esri.com/t5/python-questions/sum-a-list-of-fields/m-p/349714#M27419</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm writing a python script that loops through a number of input data sets and in the process adds a new field with a unique field name and populates it with a value at the same time the script records the field names in a list for later use. These data sets are then unioned together at the of the script and I'd like to build in the function to sum all the newly added fields into a total field at the end. I'm trying to use the calculate field tool to sum the fields, but I cannot seem to get it right and I can't seem to figure it out.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 May 2018 20:35:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sum-a-list-of-fields/m-p/349714#M27419</guid>
      <dc:creator>GrantHaynes</dc:creator>
      <dc:date>2018-05-07T20:35:56Z</dc:date>
    </item>
    <item>
      <title>Re: Sum a list of fields</title>
      <link>https://community.esri.com/t5/python-questions/sum-a-list-of-fields/m-p/349715#M27420</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Check out UpdateCursor:&amp;nbsp;&lt;A class="link-titled" href="http://pro.arcgis.com/en/pro-app/arcpy/data-access/updatecursor-class.htm" title="http://pro.arcgis.com/en/pro-app/arcpy/data-access/updatecursor-class.htm"&gt;UpdateCursor—Data Access module | ArcGIS Desktop&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Basically, read all fields, sum all values except the field you're going to write to, then write to that final field.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 May 2018 20:38:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sum-a-list-of-fields/m-p/349715#M27420</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2018-05-07T20:38:11Z</dc:date>
    </item>
    <item>
      <title>Re: Sum a list of fields</title>
      <link>https://community.esri.com/t5/python-questions/sum-a-list-of-fields/m-p/349716#M27421</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Show your script.&amp;nbsp; But basically you just need to provide the field list and if all the values are numeric it is a simple list sum in an update cursor in your new field.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Alternately, you can extract the numeric fields to a numpy array, do the summation there, then use arcpy.da.ExtendTable to permanently join the result back to your input table.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 May 2018 20:39:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sum-a-list-of-fields/m-p/349716#M27421</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2018-05-07T20:39:22Z</dc:date>
    </item>
    <item>
      <title>Re: Sum a list of fields</title>
      <link>https://community.esri.com/t5/python-questions/sum-a-list-of-fields/m-p/349717#M27422</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #595959; background-color: #f8f8f8;"&gt;I never got past trying to pass the list into the calculate field, all the fields in the list are numeric.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #595959; background-color: #f8f8f8;"&gt;arcpy.CalculateField_management(input_layer, "total", sum(URC_field_list), "PYTHON3")&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 May 2018 21:08:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sum-a-list-of-fields/m-p/349717#M27422</guid>
      <dc:creator>GrantHaynes</dc:creator>
      <dc:date>2018-05-07T21:08:27Z</dc:date>
    </item>
    <item>
      <title>Re: Sum a list of fields</title>
      <link>https://community.esri.com/t5/python-questions/sum-a-list-of-fields/m-p/349718#M27423</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can you paste the Python Snippet and results?&amp;nbsp; Since we can't see how URC_field_list is defined, it is hard to know what maybe be going on.&amp;nbsp; Also, you haven't said whether you are getting errors or unexpected results.&amp;nbsp; Either way, it helps to provide more details.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 May 2018 14:02:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sum-a-list-of-fields/m-p/349718#M27423</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2018-05-08T14:02:34Z</dc:date>
    </item>
    <item>
      <title>Re: Sum a list of fields</title>
      <link>https://community.esri.com/t5/python-questions/sum-a-list-of-fields/m-p/349719#M27424</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You might want to have a look at this post:&amp;nbsp;&lt;A href="https://community.esri.com/docs/DOC-11393"&gt;Get Statistics From All Fields in an Attribute Table&lt;/A&gt;&amp;nbsp;, but probably as others have already requested, providing the code that you have, will provide the&amp;nbsp;insights to make some suggestions of how you can solve this.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 May 2018 14:47:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sum-a-list-of-fields/m-p/349719#M27424</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2018-05-08T14:47:33Z</dc:date>
    </item>
    <item>
      <title>Re: Sum a list of fields</title>
      <link>https://community.esri.com/t5/python-questions/sum-a-list-of-fields/m-p/349720#M27425</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I started to respond to this post yesterday and held off thinking, &lt;EM&gt;hasn't this been discussed before&lt;/EM&gt;?&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migrated-users/3100"&gt;Xander Bakker&lt;/A&gt;‌&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 May 2018 15:09:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sum-a-list-of-fields/m-p/349720#M27425</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2018-05-08T15:09:31Z</dc:date>
    </item>
    <item>
      <title>Re: Sum a list of fields</title>
      <link>https://community.esri.com/t5/python-questions/sum-a-list-of-fields/m-p/349721#M27426</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The Field Calculator is the wrong tool for this task and cannot be used to solve the problem.&amp;nbsp; As others have mentioned&amp;nbsp;a SearchCursor should be used to read all of the records&amp;nbsp;except the summary record to sum the values and then an UpdateCursor can write the&amp;nbsp;result to the summary record if it exists or an InsertCursor can create a summary record if it doesn't exist.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 May 2018 15:26:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sum-a-list-of-fields/m-p/349721#M27426</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2018-05-08T15:26:21Z</dc:date>
    </item>
    <item>
      <title>Re: Sum a list of fields</title>
      <link>https://community.esri.com/t5/python-questions/sum-a-list-of-fields/m-p/349722#M27427</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you are using PRO, see&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;A href="https://www.arcgis.com/home/item.html?id=7155956bfbcb4410b42419b4c5d079f5"&gt;Descriptive statistics for multiple fields&lt;/A&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A row sum of the selected fields is one of the outputs. &amp;nbsp;&lt;/P&gt;&lt;P&gt;If you don't want to use a pre-existing solution, then pull the code you need from it. &amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 May 2018 15:30:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sum-a-list-of-fields/m-p/349722#M27427</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2018-05-08T15:30:32Z</dc:date>
    </item>
    <item>
      <title>Re: Sum a list of fields</title>
      <link>https://community.esri.com/t5/python-questions/sum-a-list-of-fields/m-p/349723#M27428</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migrated-users/4422"&gt;Joe Borgione&lt;/A&gt;&amp;nbsp;, with all the discussions already on GeoNet it is likely that this is not the first time this subject has been touched. The one I referred at in my post was a different case where the summary statistics of a field were needed. What I came up with does create statistics of multiple&amp;nbsp;value for a single&amp;nbsp; feature, so I thought it could contain some relevant code that could be tweaked&amp;nbsp;for this case.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 May 2018 15:55:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sum-a-list-of-fields/m-p/349723#M27428</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2018-05-08T15:55:43Z</dc:date>
    </item>
    <item>
      <title>Re: Sum a list of fields</title>
      <link>https://community.esri.com/t5/python-questions/sum-a-list-of-fields/m-p/349724#M27429</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Darren, that was what I needed&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 May 2018 17:45:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sum-a-list-of-fields/m-p/349724#M27429</guid>
      <dc:creator>GrantHaynes</dc:creator>
      <dc:date>2018-05-08T17:45:27Z</dc:date>
    </item>
  </channel>
</rss>

