<?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 Access content in dataframe by loc/iloc or by [ ] [ ]? in missing-QuestionPost</title>
    <link>https://community.databricks.com/t5/missing-questionpost/access-content-in-dataframe-by-loc-iloc-or-by/m-p/3220#M69</link>
    <description>&lt;P&gt;Hello, &lt;/P&gt;&lt;P&gt;&lt;B&gt;Task:&lt;/B&gt; I am trying to understand, what approach is better to access the content in DataFrame.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;My piece of code:&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;print("First approach: ", df["Purchase Address"][0])
&amp;nbsp;
print("Second approach: ", df.loc[0,"Purchase Address"])&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;These lines are equal to each other. For me more comfortable to use first version. Is there any recommends in pandas how to access the content? &lt;/P&gt;</description>
    <pubDate>Tue, 13 Jun 2023 08:02:16 GMT</pubDate>
    <dc:creator>AleksandraFrolo</dc:creator>
    <dc:date>2023-06-13T08:02:16Z</dc:date>
    <item>
      <title>Access content in dataframe by loc/iloc or by [ ] [ ]?</title>
      <link>https://community.databricks.com/t5/missing-questionpost/access-content-in-dataframe-by-loc-iloc-or-by/m-p/3220#M69</link>
      <description>&lt;P&gt;Hello, &lt;/P&gt;&lt;P&gt;&lt;B&gt;Task:&lt;/B&gt; I am trying to understand, what approach is better to access the content in DataFrame.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;My piece of code:&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;print("First approach: ", df["Purchase Address"][0])
&amp;nbsp;
print("Second approach: ", df.loc[0,"Purchase Address"])&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;These lines are equal to each other. For me more comfortable to use first version. Is there any recommends in pandas how to access the content? &lt;/P&gt;</description>
      <pubDate>Tue, 13 Jun 2023 08:02:16 GMT</pubDate>
      <guid>https://community.databricks.com/t5/missing-questionpost/access-content-in-dataframe-by-loc-iloc-or-by/m-p/3220#M69</guid>
      <dc:creator>AleksandraFrolo</dc:creator>
      <dc:date>2023-06-13T08:02:16Z</dc:date>
    </item>
    <item>
      <title>Re: Access content in dataframe by loc/iloc or by [ ] [ ]?</title>
      <link>https://community.databricks.com/t5/missing-questionpost/access-content-in-dataframe-by-loc-iloc-or-by/m-p/3221#M70</link>
      <description>&lt;P&gt;they are pretty much the same, except that loc can do a tad more:&lt;/P&gt;&lt;P&gt;&lt;A href="https://stackoverflow.com/questions/48409128/what-is-the-difference-between-using-loc-and-using-just-square-brackets-to-filte" alt="https://stackoverflow.com/questions/48409128/what-is-the-difference-between-using-loc-and-using-just-square-brackets-to-filte" target="_blank"&gt;https://stackoverflow.com/questions/48409128/what-is-the-difference-between-using-loc-and-using-just-square-brackets-to-filte&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jun 2023 13:26:08 GMT</pubDate>
      <guid>https://community.databricks.com/t5/missing-questionpost/access-content-in-dataframe-by-loc-iloc-or-by/m-p/3221#M70</guid>
      <dc:creator>-werners-</dc:creator>
      <dc:date>2023-06-13T13:26:08Z</dc:date>
    </item>
    <item>
      <title>Re: Access content in dataframe by loc/iloc or by [ ] [ ]?</title>
      <link>https://community.databricks.com/t5/missing-questionpost/access-content-in-dataframe-by-loc-iloc-or-by/m-p/3223#M72</link>
      <description>&lt;P&gt;@Aleksandra Frolova​&amp;nbsp;:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Both approaches you mentioned are valid ways to access content in a DataFrame in pandas. Let's take a closer look at each approach:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Using brackets []:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;df["Purchase Address"][0]&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Using loc or iloc:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;df.loc[0, "Purchase Address"]&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Both approaches have their advantages depending on the specific use case:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;The bracket notation [] is simpler and more concise, making it suitable for quick access to specific elements or simple slicing operations. It is commonly used when you have a straightforward DataFrame structure or when you want to access a specific column or row quickly.&lt;/LI&gt;&lt;LI&gt;The loc or iloc indexer is more versatile and powerful. It allows you to access elements using label-based indexing (loc) or integer-based indexing (iloc). This is especially useful when you have complex DataFrame structures, customized row and column labels, or when you need more control over your indexing operations.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jun 2023 07:53:22 GMT</pubDate>
      <guid>https://community.databricks.com/t5/missing-questionpost/access-content-in-dataframe-by-loc-iloc-or-by/m-p/3223#M72</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-06-14T07:53:22Z</dc:date>
    </item>
  </channel>
</rss>

