<?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: arcpy.mapping.ListDataFrames - why the array index [0] on the end? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/arcpy-mapping-listdataframes-why-the-array-index-0/m-p/275897#M21279</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;It's not a quirk, the function returns a list object.&amp;nbsp; In order to access the underlying data inside the list, you need to tell the object what information you need by letting the list know I want some piece of information in position X.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;To be even more general, functions return a specific data type.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope this helps.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 02 Dec 2011 10:11:33 GMT</pubDate>
    <dc:creator>AndrewChapkowski</dc:creator>
    <dc:date>2011-12-02T10:11:33Z</dc:date>
    <item>
      <title>arcpy.mapping.ListDataFrames - why the array index [0] on the end?</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-mapping-listdataframes-why-the-array-index-0/m-p/275896#M21278</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Can someone please explain why we need to do this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;instead of just:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;df = arcpy.mapping.ListDataFrames(mxd, "Layers")&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If I just say &lt;/SPAN&gt;&lt;PRE class="plain" name="code"&gt;df = arcpy.mapping.ListDataFrames(mxd)&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;SPAN&gt; then I can loop through the df list object by doing something like&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;for i in df:
&amp;nbsp; print i.name&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But if I want to set variable df to a known data frame (in this case "Layers") why do I need to specify the index number [0] at the end of the code line?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If anyone can explain this quirk I'd be really grateful. Thanks&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Dec 2011 07:41:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-mapping-listdataframes-why-the-array-index-0/m-p/275896#M21278</guid>
      <dc:creator>JT2</dc:creator>
      <dc:date>2011-12-02T07:41:35Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.mapping.ListDataFrames - why the array index [0] on the end?</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-mapping-listdataframes-why-the-array-index-0/m-p/275897#M21279</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;It's not a quirk, the function returns a list object.&amp;nbsp; In order to access the underlying data inside the list, you need to tell the object what information you need by letting the list know I want some piece of information in position X.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;To be even more general, functions return a specific data type.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope this helps.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Dec 2011 10:11:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-mapping-listdataframes-why-the-array-index-0/m-p/275897#M21279</guid>
      <dc:creator>AndrewChapkowski</dc:creator>
      <dc:date>2011-12-02T10:11:33Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.mapping.ListDataFrames - why the array index [0] on the end?</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-mapping-listdataframes-why-the-array-index-0/m-p/275898#M21280</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;But if I want to set variable df to a known data frame (in this case "Layers") why do I need to specify the index number [0] at the end of the code line?&lt;BR /&gt;&lt;BR /&gt;If anyone can explain this quirk I'd be really grateful. Thanks&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You don't. Without [0], df is a list of data frames, regardless of whether you explicitly specify a data frame, e.g. "Layers." Consider if there are multiple data frames with the same name. Of course, with [0] - or generally &lt;N&gt;, df is a single data frame.&lt;/N&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;"Layers" is merely a filter that removes any data frames not named "Layers."&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Scott&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 03 Dec 2011 03:21:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-mapping-listdataframes-why-the-array-index-0/m-p/275898#M21280</guid>
      <dc:creator>ScottOatley</dc:creator>
      <dc:date>2011-12-03T03:21:26Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.mapping.ListDataFrames - why the array index [0] on the end?</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-mapping-listdataframes-why-the-array-index-0/m-p/275899#M21281</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;OK Thank you. I understand, so it's basically Python syntax, being the difference between a list object, and an individual member of that list, indexed by the square brackets []&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Presumably if I had two data frames called "Layers" then I could index them using [0] and [1]?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Dec 2011 07:16:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-mapping-listdataframes-why-the-array-index-0/m-p/275899#M21281</guid>
      <dc:creator>JT2</dc:creator>
      <dc:date>2011-12-05T07:16:30Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.mapping.ListDataFrames - why the array index [0] on the end?</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-mapping-listdataframes-why-the-array-index-0/m-p/275900#M21282</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&lt;BR /&gt;&lt;BR /&gt;Presumably if I had two data frames called "Layers" then I could index them using [0] and [1]?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Correct &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Dec 2011 13:29:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-mapping-listdataframes-why-the-array-index-0/m-p/275900#M21282</guid>
      <dc:creator>ArkadiuszMatoszka</dc:creator>
      <dc:date>2011-12-05T13:29:47Z</dc:date>
    </item>
  </channel>
</rss>

