<?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: python Built-In Types for sets in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/python-built-in-types-for-sets/m-p/645237#M50305</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;An example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;a, b = {1, 2, 3, 4}, {3, 4, 7, 10}
c = a - b
print c&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;will print&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;set([1, 2])&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Or say we have two tables (table_one and table_two) with a field named "name". You want all the names in table_one that aren't in table_two.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;set_one = set(r[0] for r in arcpy.da.SearchCursor("table_one", "name"))
set_two = set(r[0] for r in arcpy.da.SearchCursor("table_one", "name"))
print "Items unique to table_one: {}".format(", ".join(sorted(set_one - set_two)))&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 03:24:00 GMT</pubDate>
    <dc:creator>JasonScheirer</dc:creator>
    <dc:date>2021-12-12T03:24:00Z</dc:date>
    <item>
      <title>python Built-In Types for sets</title>
      <link>https://community.esri.com/t5/python-questions/python-built-in-types-for-sets/m-p/645236#M50304</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Below is an example given, in the python literature, for a python built-in type: The instructions say: Returns a new set with elements in the set that are not in the others. Is there someone that can provide an example of how this built-in is used? A world of thanks. Larry Adgate-see attachment&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;set - other - ....&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Oct 2013 15:33:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-built-in-types-for-sets/m-p/645236#M50304</guid>
      <dc:creator>LarryAdgate</dc:creator>
      <dc:date>2013-10-30T15:33:49Z</dc:date>
    </item>
    <item>
      <title>Re: python Built-In Types for sets</title>
      <link>https://community.esri.com/t5/python-questions/python-built-in-types-for-sets/m-p/645237#M50305</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;An example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;a, b = {1, 2, 3, 4}, {3, 4, 7, 10}
c = a - b
print c&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;will print&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;set([1, 2])&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Or say we have two tables (table_one and table_two) with a field named "name". You want all the names in table_one that aren't in table_two.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;set_one = set(r[0] for r in arcpy.da.SearchCursor("table_one", "name"))
set_two = set(r[0] for r in arcpy.da.SearchCursor("table_one", "name"))
print "Items unique to table_one: {}".format(", ".join(sorted(set_one - set_two)))&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 03:24:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-built-in-types-for-sets/m-p/645237#M50305</guid>
      <dc:creator>JasonScheirer</dc:creator>
      <dc:date>2021-12-12T03:24:00Z</dc:date>
    </item>
    <item>
      <title>Re: python Built-In Types for sets</title>
      <link>https://community.esri.com/t5/python-questions/python-built-in-types-for-sets/m-p/645238#M50306</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Jason, the code for table_one and table_two works well for text only. Can it be modified if the fields in the shapefiles were double or a float?, Thanks Larry&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Oct 2013 20:03:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-built-in-types-for-sets/m-p/645238#M50306</guid>
      <dc:creator>LarryAdgate</dc:creator>
      <dc:date>2013-10-31T20:03:16Z</dc:date>
    </item>
    <item>
      <title>Re: python Built-In Types for sets</title>
      <link>https://community.esri.com/t5/python-questions/python-built-in-types-for-sets/m-p/645239#M50307</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You can use sets to find the unique values of a bunch of values...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Oct 2013 20:07:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-built-in-types-for-sets/m-p/645239#M50307</guid>
      <dc:creator>StacyRendall1</dc:creator>
      <dc:date>2013-10-31T20:07:24Z</dc:date>
    </item>
    <item>
      <title>Re: python Built-In Types for sets</title>
      <link>https://community.esri.com/t5/python-questions/python-built-in-types-for-sets/m-p/645240#M50308</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;It works for most basic types, so the same code would work on doubles/floats/ints/whatever as well.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Oct 2013 20:17:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-built-in-types-for-sets/m-p/645240#M50308</guid>
      <dc:creator>JasonScheirer</dc:creator>
      <dc:date>2013-10-31T20:17:29Z</dc:date>
    </item>
    <item>
      <title>Re: python Built-In Types for sets</title>
      <link>https://community.esri.com/t5/python-questions/python-built-in-types-for-sets/m-p/645241#M50309</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I like sets a lot. Most people just use them for calculating unique values, but the real power is in using the set()'s union, intersect, difference, etc. functions... Extreemly fast and efficient!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;One practical example I use this for is I have this large polygon layer I need to convert to raster in order to get elevation and slope values (from a DEM) using zonal statsistics. A number of the polygons (20% or so) are too small to be converted to a raster, and for those, I still need to get spot elevation and slope values for the centroids via the Sample tool.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Basically I make a set for the OIDs for all my original polygons, and another set for the VALUEs of the raster version (which are the OIDs that "made it" to the raster). Now I need to figure out what polygons I must convert to centroids (so as to run the sample tool). BTW: Dealing with&amp;nbsp; 2.5 million polgons.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; set1 = set((1,2,3,4,5,6,7,8,9,10)) #all the OIDs in the polygon layer&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; set2 = set((1,2,3,7,8,9)) #the OIDs that made it to the raster layer&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; print set1.difference(set2)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;set([10, 4, 5, 6]) #The polygon OIDs that I need to derive centroids for and then use the Sample tool on&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Oct 2013 20:37:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-built-in-types-for-sets/m-p/645241#M50309</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2013-10-31T20:37:58Z</dc:date>
    </item>
  </channel>
</rss>

