<?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 Min and Max values in an attribute table in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/min-and-max-values-in-an-attribute-table/m-p/699255#M54195</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This seems like a pretty straight forward question, but I can't seem to find the answer online so I am hoping someone can help me.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1) I have a field in an attribute table, lets call it Index_values and I would like to find the range of values within that field.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;My plan was to use the min() and max() function, giving me the lowest and highest value.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;2) Then I would like to break this range up into 5 equal categories.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;How I was going to do this was max - min, then divide that by 5&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;example max = 12, min = 2&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;12 - 2/5 = 2&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Then I would add 2, to the min value and go up from there...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Therefore, that categories would be:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2-4&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;4-6&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;6-8&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;8-10&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;10-12&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;However, my problem is, I cannot get the min/max function to look through the Index_value field within that table.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there something I am missing, or an easier way to find the range and divide that range into categories?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Jeremy&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 27 Jan 2012 15:40:27 GMT</pubDate>
    <dc:creator>JeremyTibbetts1</dc:creator>
    <dc:date>2012-01-27T15:40:27Z</dc:date>
    <item>
      <title>Min and Max values in an attribute table</title>
      <link>https://community.esri.com/t5/python-questions/min-and-max-values-in-an-attribute-table/m-p/699255#M54195</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This seems like a pretty straight forward question, but I can't seem to find the answer online so I am hoping someone can help me.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1) I have a field in an attribute table, lets call it Index_values and I would like to find the range of values within that field.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;My plan was to use the min() and max() function, giving me the lowest and highest value.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;2) Then I would like to break this range up into 5 equal categories.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;How I was going to do this was max - min, then divide that by 5&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;example max = 12, min = 2&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;12 - 2/5 = 2&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Then I would add 2, to the min value and go up from there...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Therefore, that categories would be:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2-4&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;4-6&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;6-8&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;8-10&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;10-12&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;However, my problem is, I cannot get the min/max function to look through the Index_value field within that table.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there something I am missing, or an easier way to find the range and divide that range into categories?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Jeremy&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Jan 2012 15:40:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/min-and-max-values-in-an-attribute-table/m-p/699255#M54195</guid>
      <dc:creator>JeremyTibbetts1</dc:creator>
      <dc:date>2012-01-27T15:40:27Z</dc:date>
    </item>
    <item>
      <title>Re: Min and Max values in an attribute table</title>
      <link>https://community.esri.com/t5/python-questions/min-and-max-values-in-an-attribute-table/m-p/699256#M54196</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Use a search cursor and append all the values from that attribute to a new Python list.&amp;nbsp; Sort the list.&amp;nbsp; The first item in the list is the min value and the last is the last value.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;theitems = []
rows = arcpy.SearchCursor(inlayer)
for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; theitems.append(row.getValue(somefieldname))
del rows
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
theitems.sort()
min = theitems[0]
max = theitems[-1]&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 05:25:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/min-and-max-values-in-an-attribute-table/m-p/699256#M54196</guid>
      <dc:creator>GerryGabrisch</dc:creator>
      <dc:date>2021-12-12T05:25:44Z</dc:date>
    </item>
    <item>
      <title>Re: Min and Max values in an attribute table</title>
      <link>https://community.esri.com/t5/python-questions/min-and-max-values-in-an-attribute-table/m-p/699257#M54197</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Another way, which is faster and involves fewer lines of code... But for which you can't use derive other usefull stats such as mean or StdDev...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;myField = "MY_FIELD"
minValue = arcpy.SearchCursor(inlayer, "", "", "", myField + " A").next().getValue(myField) #Get 1st row in ascending cursor sort
maxValue = arcpy.SearchCursor(inlayer, "", "", "", myField + " D").next().getValue(myField) #Get 1st row in descending cursor sort&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 05:25:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/min-and-max-values-in-an-attribute-table/m-p/699257#M54197</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2021-12-12T05:25:47Z</dc:date>
    </item>
    <item>
      <title>Re: Min and Max values in an attribute table</title>
      <link>https://community.esri.com/t5/python-questions/min-and-max-values-in-an-attribute-table/m-p/699258#M54198</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Dan Patterson has posted some Python code in arcscripts (not arcpy, but the translation is not difficult) here:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://arcscripts.esri.com/details.asp?dbid=14173"&gt;http://arcscripts.esri.com/details.asp?dbid=14173&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you want to take the approach of creating a python list, there are some great methods in python:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://adorio-research.org/wordpress/?p=125"&gt;http://adorio-research.org/wordpress/?p=125&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Another tack would be to build a little script or model that uses Get Count, Sort and Calculate Field to just do an integer division to determine the class number. This would be simple and fast but wouldn't be very sophisticated for distributions that don't break into quantiles so easily.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Jan 2012 16:05:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/min-and-max-values-in-an-attribute-table/m-p/699258#M54198</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2012-01-30T16:05:29Z</dc:date>
    </item>
  </channel>
</rss>

