<?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 Selection Cursor Question in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/selection-cursor-question/m-p/171130#M13147</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;I have a feature class which looks like this:&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="image-1 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/368339_FeatureClass.PNG" style="width: 620px; height: 726px;" /&gt;&lt;/P&gt;&lt;P&gt;What I need to do is loop through each group of records in the NAME field where the value is the same (these are community names) and perform a calculation which is&amp;nbsp;based on the Area values for each USE_CATEGORY and the Sum of all USE_CATEGORY Area values (which will give us the total area for the community). I think the following excel snapshot outlines the calculation to be done against each community (NAME):&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="image-2 jive-image j-img-original" src="/legacyfs/online/368341_EXCEL 1.PNG" style="width: 620px; height: 355px;" /&gt;&lt;/P&gt;&lt;P&gt;The end goal is to create a new table that will show the community along with the calculated diversity index for that community:&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="image-3 jive-image j-img-original" src="/legacyfs/online/368342_EXCEL 2.PNG" style="height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;I'm thinking some sort of loop would be used to select the records for each community, but I'm not sure of the best way to go about that and also how do you move on to select the records for the next community. Looking for some guidance and ideas on how to best get this done.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks everyone,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 23 Aug 2017 19:21:55 GMT</pubDate>
    <dc:creator>ChrisHolmes</dc:creator>
    <dc:date>2017-08-23T19:21:55Z</dc:date>
    <item>
      <title>Selection Cursor Question</title>
      <link>https://community.esri.com/t5/python-questions/selection-cursor-question/m-p/171130#M13147</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;I have a feature class which looks like this:&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="image-1 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/368339_FeatureClass.PNG" style="width: 620px; height: 726px;" /&gt;&lt;/P&gt;&lt;P&gt;What I need to do is loop through each group of records in the NAME field where the value is the same (these are community names) and perform a calculation which is&amp;nbsp;based on the Area values for each USE_CATEGORY and the Sum of all USE_CATEGORY Area values (which will give us the total area for the community). I think the following excel snapshot outlines the calculation to be done against each community (NAME):&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="image-2 jive-image j-img-original" src="/legacyfs/online/368341_EXCEL 1.PNG" style="width: 620px; height: 355px;" /&gt;&lt;/P&gt;&lt;P&gt;The end goal is to create a new table that will show the community along with the calculated diversity index for that community:&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="image-3 jive-image j-img-original" src="/legacyfs/online/368342_EXCEL 2.PNG" style="height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;I'm thinking some sort of loop would be used to select the records for each community, but I'm not sure of the best way to go about that and also how do you move on to select the records for the next community. Looking for some guidance and ideas on how to best get this done.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks everyone,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Aug 2017 19:21:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/selection-cursor-question/m-p/171130#M13147</guid>
      <dc:creator>ChrisHolmes</dc:creator>
      <dc:date>2017-08-23T19:21:55Z</dc:date>
    </item>
    <item>
      <title>Re: Selection Cursor Question</title>
      <link>https://community.esri.com/t5/python-questions/selection-cursor-question/m-p/171131#M13148</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;STRONG&gt;&lt;A href="http://pro.arcgis.com/en/pro-app/tool-reference/analysis/summary-statistics.htm"&gt;Summary Statistics &lt;/A&gt;&lt;/STRONG&gt;will provide you with some of the data...&amp;nbsp;&lt;/P&gt;&lt;P&gt;From that table, you can do your calculations using the area data&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Aug 2017 19:38:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/selection-cursor-question/m-p/171131#M13148</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2017-08-23T19:38:29Z</dc:date>
    </item>
    <item>
      <title>Re: Selection Cursor Question</title>
      <link>https://community.esri.com/t5/python-questions/selection-cursor-question/m-p/171132#M13149</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I actually used Summary Statistics to create the table that has the 1495 records in it. The original table had around 35000 records. I used the Summary Statistics to group by NAME and USE_CATEGORY and SUM Area.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Where I'm stumped with now is how&amp;nbsp;to write the code to pull the records for each community, complete the calculation then move onto the next community in the list. Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Aug 2017 20:15:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/selection-cursor-question/m-p/171132#M13149</guid>
      <dc:creator>ChrisHolmes</dc:creator>
      <dc:date>2017-08-23T20:15:30Z</dc:date>
    </item>
    <item>
      <title>Re: Selection Cursor Question</title>
      <link>https://community.esri.com/t5/python-questions/selection-cursor-question/m-p/171133#M13150</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You will need to get a list of the unique community names, from there you could batch a select by attributes within a loop, do the calculation update store the result then move on.&amp;nbsp; Perhaps people that work with cursors more often will leap in, I would do this all in numpy (some use Pandas) and save out to a summary table there.&amp;nbsp; numpy and pandas are better at vectorizing queries and calculations than most cursor operations.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Aug 2017 20:22:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/selection-cursor-question/m-p/171133#M13150</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2017-08-23T20:22:54Z</dc:date>
    </item>
    <item>
      <title>Re: Selection Cursor Question</title>
      <link>https://community.esri.com/t5/python-questions/selection-cursor-question/m-p/171134#M13151</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I got a script working so thought I'd share it. Seems to get the job done. Down the road when I have a better understanding of pandas I think I'll give that a try as it does seem the dataframe is the way to go.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; arcpy
&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; numpy &lt;SPAN class="keyword token"&gt;as&lt;/SPAN&gt; np
updateFc &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'X:/gis/ludiversity/ludiversity.gdb/CommunityStats'&lt;/SPAN&gt;
updateFields &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'NAME'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'SUM_Shape_Area'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'DIVERSITY_INDEX'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
searchFc &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'X:/gis/ludiversity/ludiversity.gdb/Community_UseCategoryStats'&lt;/SPAN&gt;
searchFields &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'NAME'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'USE_CATEGORY'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'SUM_Shape_Area'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;with&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;da&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;UpdateCursor&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;updateFc&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;updateFields&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;as&lt;/SPAN&gt; uCur&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="comment token"&gt;#loop through each community record in updateFc&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; uRow &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; uCur&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; whereClause &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"NAME = '"&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; uRow&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"'"&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;with&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;da&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SearchCursor&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;searchFc&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;searchFields&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;whereClause&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;as&lt;/SPAN&gt; selCur&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; interimValue &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;#list to store calculation for each USE_CATEGORY value&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; sRow &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; selCur&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="comment token"&gt;#divide the USE_CATEGORY area by the total community area then square that number &amp;amp; append it to the list&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; interimValue&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;append&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;np&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;square&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;sRow&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;2&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;/&lt;/SPAN&gt;uRow&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="comment token"&gt;#sum the values in the list then subtract that value from 1 to get the diversity index for the community&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uRow&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;2&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;1&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;-&lt;/SPAN&gt; sum&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;interimValue&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uCur&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;updateRow&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;uRow&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 08:52:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/selection-cursor-question/m-p/171134#M13151</guid>
      <dc:creator>ChrisHolmes</dc:creator>
      <dc:date>2021-12-11T08:52:07Z</dc:date>
    </item>
  </channel>
</rss>

