<?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 Show all distinct values per column in dataframe Problem Statement:I want to see all the distinct values per column for my entire table, but a SQL que... in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/show-all-distinct-values-per-column-in-dataframe-problem/m-p/13478#M8151</link>
    <description>&lt;P&gt;&lt;B&gt;&lt;U&gt;Show all distinct values per column in dataframe&lt;/U&gt;&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;Problem Statement:&lt;/B&gt;&lt;/P&gt;&lt;P&gt;I want to see all the distinct values per column for my entire table, but a SQL query with a collect_set() on every column is not dynamic and too long to write.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use this code to show the output below:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;%python
&amp;nbsp;
from pyspark.sql.functions import col, collect_set
&amp;nbsp;
distincts = df.agg(*(collect_set(col(c)).alias(c) for c in df.columns))
distincts.display()&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="collect set table"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/2405i74B6A77D665D7593/image-size/large?v=v2&amp;amp;px=999" role="button" title="collect set table" alt="collect set table" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 14 Oct 2021 00:45:06 GMT</pubDate>
    <dc:creator>Artem_Y</dc:creator>
    <dc:date>2021-10-14T00:45:06Z</dc:date>
    <item>
      <title>Show all distinct values per column in dataframe Problem Statement:I want to see all the distinct values per column for my entire table, but a SQL que...</title>
      <link>https://community.databricks.com/t5/data-engineering/show-all-distinct-values-per-column-in-dataframe-problem/m-p/13478#M8151</link>
      <description>&lt;P&gt;&lt;B&gt;&lt;U&gt;Show all distinct values per column in dataframe&lt;/U&gt;&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;Problem Statement:&lt;/B&gt;&lt;/P&gt;&lt;P&gt;I want to see all the distinct values per column for my entire table, but a SQL query with a collect_set() on every column is not dynamic and too long to write.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use this code to show the output below:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;%python
&amp;nbsp;
from pyspark.sql.functions import col, collect_set
&amp;nbsp;
distincts = df.agg(*(collect_set(col(c)).alias(c) for c in df.columns))
distincts.display()&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="collect set table"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/2405i74B6A77D665D7593/image-size/large?v=v2&amp;amp;px=999" role="button" title="collect set table" alt="collect set table" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Oct 2021 00:45:06 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/show-all-distinct-values-per-column-in-dataframe-problem/m-p/13478#M8151</guid>
      <dc:creator>Artem_Y</dc:creator>
      <dc:date>2021-10-14T00:45:06Z</dc:date>
    </item>
    <item>
      <title>Re: Show all distinct values per column in dataframe Problem Statement:I want to see all the distinct values per column for my entire table, but a SQL que...</title>
      <link>https://community.databricks.com/t5/data-engineering/show-all-distinct-values-per-column-in-dataframe-problem/m-p/13479#M8152</link>
      <description>&lt;P&gt;@Artem Yevtushenko​&amp;nbsp;- This is great! Thank you for sharing!&lt;/P&gt;</description>
      <pubDate>Thu, 14 Oct 2021 17:25:19 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/show-all-distinct-values-per-column-in-dataframe-problem/m-p/13479#M8152</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-10-14T17:25:19Z</dc:date>
    </item>
  </channel>
</rss>

