<?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: how to get unique values of a column in pyspark dataframe in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/how-to-get-unique-values-of-a-column-in-pyspark-dataframe/m-p/29488#M21212</link>
    <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Hi, tried using .distinct().show() as advised, but am getting the error TypeError: 'DataFrame' object is not callable. &lt;/P&gt;
&lt;P&gt;The dataframe was read in from a csv file using spark.read.csv, other functions like describe works on the df. any reason for this? how should I go about retrieving the list of unique values in this case? &lt;/P&gt;
&lt;P&gt;sorry if question is very basic. noob at this. Thanks!&lt;/P&gt; 
&lt;P&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 15 Jun 2017 03:14:59 GMT</pubDate>
    <dc:creator>ShuminWu</dc:creator>
    <dc:date>2017-06-15T03:14:59Z</dc:date>
    <item>
      <title>how to get unique values of a column in pyspark dataframe</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-get-unique-values-of-a-column-in-pyspark-dataframe/m-p/29486#M21210</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;like in pandas I usually do df['columnname'].unique()&lt;/P&gt; 
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Sep 2016 07:01:18 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-get-unique-values-of-a-column-in-pyspark-dataframe/m-p/29486#M21210</guid>
      <dc:creator>satya</dc:creator>
      <dc:date>2016-09-08T07:01:18Z</dc:date>
    </item>
    <item>
      <title>Re: how to get unique values of a column in pyspark dataframe</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-get-unique-values-of-a-column-in-pyspark-dataframe/m-p/29487#M21211</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;df.select("columnname").distinct().show()&lt;/P&gt; 
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Apr 2017 00:07:48 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-get-unique-values-of-a-column-in-pyspark-dataframe/m-p/29487#M21211</guid>
      <dc:creator>raela</dc:creator>
      <dc:date>2017-04-05T00:07:48Z</dc:date>
    </item>
    <item>
      <title>Re: how to get unique values of a column in pyspark dataframe</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-get-unique-values-of-a-column-in-pyspark-dataframe/m-p/29488#M21212</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Hi, tried using .distinct().show() as advised, but am getting the error TypeError: 'DataFrame' object is not callable. &lt;/P&gt;
&lt;P&gt;The dataframe was read in from a csv file using spark.read.csv, other functions like describe works on the df. any reason for this? how should I go about retrieving the list of unique values in this case? &lt;/P&gt;
&lt;P&gt;sorry if question is very basic. noob at this. Thanks!&lt;/P&gt; 
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2017 03:14:59 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-get-unique-values-of-a-column-in-pyspark-dataframe/m-p/29488#M21212</guid>
      <dc:creator>ShuminWu</dc:creator>
      <dc:date>2017-06-15T03:14:59Z</dc:date>
    </item>
    <item>
      <title>Re: how to get unique values of a column in pyspark dataframe</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-get-unique-values-of-a-column-in-pyspark-dataframe/m-p/29489#M21213</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;this code returns data that's not iterable, i.e. I see the distinct data bit am not able to iterate over it in code. Any other way that enables me to do it. I tried using toPandas() to convert in it into Pandas df and then get the iterable with unique values. However, running into '' Pandas not found' error message. How can I install Pandas i my pyspark env, if my local already has Pandas running!&lt;/P&gt; 
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Dec 2018 01:14:43 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-get-unique-values-of-a-column-in-pyspark-dataframe/m-p/29489#M21213</guid>
      <dc:creator>AbhishekYada</dc:creator>
      <dc:date>2018-12-17T01:14:43Z</dc:date>
    </item>
    <item>
      <title>Re: how to get unique values of a column in pyspark dataframe</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-get-unique-values-of-a-column-in-pyspark-dataframe/m-p/29490#M21214</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;To get the count of the distinct values: &lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;df.select(F.countDistinct("colx")).show()&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or to count the number of records for each distinct value:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;df.groupBy("colx").count().orderBy().show()&lt;/CODE&gt;&lt;/PRE&gt; 
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Apr 2019 11:18:21 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-get-unique-values-of-a-column-in-pyspark-dataframe/m-p/29490#M21214</guid>
      <dc:creator>Rodneyjoyce</dc:creator>
      <dc:date>2019-04-22T11:18:21Z</dc:date>
    </item>
    <item>
      <title>Re: how to get unique values of a column in pyspark dataframe</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-get-unique-values-of-a-column-in-pyspark-dataframe/m-p/29491#M21215</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Hi, this worked for me.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;distinct_ids = [x.id for x in data.select('id').distinct().collect()]
&lt;/CODE&gt;&lt;/PRE&gt; 
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Jul 2020 22:05:32 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-get-unique-values-of-a-column-in-pyspark-dataframe/m-p/29491#M21215</guid>
      <dc:creator>ldfo</dc:creator>
      <dc:date>2020-07-01T22:05:32Z</dc:date>
    </item>
    <item>
      <title>Re: how to get unique values of a column in pyspark dataframe</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-get-unique-values-of-a-column-in-pyspark-dataframe/m-p/29492#M21216</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;nice way, also very "pythonic" minded&lt;/P&gt; 
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Sep 2020 15:03:03 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-get-unique-values-of-a-column-in-pyspark-dataframe/m-p/29492#M21216</guid>
      <dc:creator>Ger_Martinez</dc:creator>
      <dc:date>2020-09-02T15:03:03Z</dc:date>
    </item>
    <item>
      <title>Re: how to get unique values of a column in pyspark dataframe</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-get-unique-values-of-a-column-in-pyspark-dataframe/m-p/29493#M21217</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Thanks for this. The latter worked well for me. However, sorry for my ignorance here but what is F in the first one? The code works without the F. !The latter worked well for me.&lt;/P&gt; 
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 22 Nov 2020 21:36:11 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-get-unique-values-of-a-column-in-pyspark-dataframe/m-p/29493#M21217</guid>
      <dc:creator>AnujGupta</dc:creator>
      <dc:date>2020-11-22T21:36:11Z</dc:date>
    </item>
    <item>
      <title>Re: how to get unique values of a column in pyspark dataframe</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-get-unique-values-of-a-column-in-pyspark-dataframe/m-p/29494#M21218</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;If you want to use the values to make some processing, this is the way to go.&lt;/P&gt; 
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 07 Aug 2021 05:43:41 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-get-unique-values-of-a-column-in-pyspark-dataframe/m-p/29494#M21218</guid>
      <dc:creator>AbimaelDomingue</dc:creator>
      <dc:date>2021-08-07T05:43:41Z</dc:date>
    </item>
    <item>
      <title>Re: how to get unique values of a column in pyspark dataframe</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-get-unique-values-of-a-column-in-pyspark-dataframe/m-p/29495#M21219</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;If you just want to print the results and not use the results for other processing, this is the way to go.&lt;/P&gt; 
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 07 Aug 2021 05:45:16 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-get-unique-values-of-a-column-in-pyspark-dataframe/m-p/29495#M21219</guid>
      <dc:creator>AbimaelDomingue</dc:creator>
      <dc:date>2021-08-07T05:45:16Z</dc:date>
    </item>
    <item>
      <title>Re: how to get unique values of a column in pyspark dataframe</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-get-unique-values-of-a-column-in-pyspark-dataframe/m-p/29496#M21220</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;If you want to use the results for some other data processing this is the way to go.&lt;/P&gt; 
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 07 Aug 2021 05:46:12 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-get-unique-values-of-a-column-in-pyspark-dataframe/m-p/29496#M21220</guid>
      <dc:creator>AbimaelDomingue</dc:creator>
      <dc:date>2021-08-07T05:46:12Z</dc:date>
    </item>
  </channel>
</rss>

