<?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 range of fields and find largest in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/sum-range-of-fields-and-find-largest/m-p/210987#M16304</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This can be done in any number of ways - as you've mentioned numpy, or Update Cursor, and also Field Calculator. You just need to choose one, get started, and then post what you've got for more help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 01 Mar 2016 18:54:34 GMT</pubDate>
    <dc:creator>DarrenWiens2</dc:creator>
    <dc:date>2016-03-01T18:54:34Z</dc:date>
    <item>
      <title>SUM range of fields and find largest</title>
      <link>https://community.esri.com/t5/python-questions/sum-range-of-fields-and-find-largest/m-p/210986#M16303</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a point feature class with fields representing hourly precipitation amounts for a particular storm and many thousands of records.&amp;nbsp; The number of fields will vary from storm to storm.&amp;nbsp; I am trying to get the max 6 hour precipitation amounts.&amp;nbsp; I need it to list fields, SUM row for 1st-6th field, and assign it to Max Precip Field.&amp;nbsp; Then SUM row for fields 2-7 and if it is larger than 1-6 assign that value, if not leave it the 1-6 value.&amp;nbsp; Need this to loop till the end of the fields and for every record.&amp;nbsp; Can somebody recommend the best way and some syntax to accomplish this?&amp;nbsp; Would this be best accomplished with a numpy array or Update cursor?&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Mar 2016 18:46:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sum-range-of-fields-and-find-largest/m-p/210986#M16303</guid>
      <dc:creator>JAKERODEL</dc:creator>
      <dc:date>2016-03-01T18:46:05Z</dc:date>
    </item>
    <item>
      <title>Re: SUM range of fields and find largest</title>
      <link>https://community.esri.com/t5/python-questions/sum-range-of-fields-and-find-largest/m-p/210987#M16304</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This can be done in any number of ways - as you've mentioned numpy, or Update Cursor, and also Field Calculator. You just need to choose one, get started, and then post what you've got for more help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Mar 2016 18:54:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sum-range-of-fields-and-find-largest/m-p/210987#M16304</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2016-03-01T18:54:34Z</dc:date>
    </item>
    <item>
      <title>Re: SUM range of fields and find largest</title>
      <link>https://community.esri.com/t5/python-questions/sum-range-of-fields-and-find-largest/m-p/210988#M16305</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What version of ArcMap are you using?&amp;nbsp; I ask because new support for several useful Python packages was included at 10.4.&amp;nbsp; Specifically, Pandas is now supported and &lt;A href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.rolling_max.html" rel="nofollow noopener noreferrer" target="_blank"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;pandas.rolling_max&lt;/SPAN&gt; &lt;/A&gt;was built for this type of situation.&amp;nbsp; If you are working with 10.3.1 or earlier, there is a moving average recipe in the Python &lt;A href="https://docs.python.org/2/library/collections.html#deque-recipes" rel="nofollow noopener noreferrer" target="_blank"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;deque&lt;/SPAN&gt; Recipes &lt;/A&gt;​that can be easily modified to return the sum instead of average and then used to find the maximum:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;gt;&amp;gt;&amp;gt; def moving_sum(iterable, window_size=1):
&amp;nbsp;&amp;nbsp;&amp;nbsp; from collections import deque
&amp;nbsp;&amp;nbsp;&amp;nbsp; from itertools import islice
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; it = iter(iterable)
&amp;nbsp;&amp;nbsp;&amp;nbsp; d = deque(islice(it, window_size-1))
&amp;nbsp;&amp;nbsp;&amp;nbsp; d.appendleft(0)
&amp;nbsp;&amp;nbsp;&amp;nbsp; s = sum(d)
&amp;nbsp;&amp;nbsp;&amp;nbsp; for elem in it:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; s += elem - d.popleft()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; d.append(elem)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; yield s&amp;nbsp; 
&amp;gt;&amp;gt;&amp;gt; rain_hour = (0.25, 0.8, 0.13, 0.08, 0.55, 0.34, 0.35, 0.17, 0.02, 0.6, 0.14)
&amp;gt;&amp;gt;&amp;gt; max(moving_sum(rain_hour, 6))
2.2500000000000004
&amp;gt;&amp;gt;&amp;gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 10:23:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sum-range-of-fields-and-find-largest/m-p/210988#M16305</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2021-12-11T10:23:37Z</dc:date>
    </item>
  </channel>
</rss>

