<?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 Pivot on multiple columns in Get Started Discussions</title>
    <link>https://community.databricks.com/t5/get-started-discussions/pivot-on-multiple-columns/m-p/54092#M6190</link>
    <description>&lt;P&gt;I want to&amp;nbsp;&lt;SPAN&gt;pass multiple column as argument to&lt;/SPAN&gt;&amp;nbsp;pivot a dataframe &lt;SPAN&gt;&amp;nbsp;in pyspark pivot like&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;mydf.groupBy(&lt;/SPAN&gt;&lt;SPAN&gt;"id"&lt;/SPAN&gt;&lt;SPAN&gt;).pivot(&lt;/SPAN&gt;&lt;SPAN&gt;"day"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;"city"&lt;/SPAN&gt;&lt;SPAN&gt;).agg(F.&lt;/SPAN&gt;&lt;SPAN&gt;sum&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;"price"&lt;/SPAN&gt;&lt;SPAN&gt;).alias(&lt;/SPAN&gt;&lt;SPAN&gt;"price"&lt;/SPAN&gt;&lt;SPAN&gt;),F.&lt;/SPAN&gt;&lt;SPAN&gt;sum&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;"units"&lt;/SPAN&gt;&lt;SPAN&gt;).alias(&lt;/SPAN&gt;&lt;SPAN&gt;"units"&lt;/SPAN&gt;&lt;SPAN&gt;)).show().&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;One way I found is to create multiple df with different pivot and join them which will result in multiple scan. But is there any other way to do this?&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Tue, 28 Nov 2023 11:50:43 GMT</pubDate>
    <dc:creator>memo</dc:creator>
    <dc:date>2023-11-28T11:50:43Z</dc:date>
    <item>
      <title>Pivot on multiple columns</title>
      <link>https://community.databricks.com/t5/get-started-discussions/pivot-on-multiple-columns/m-p/54092#M6190</link>
      <description>&lt;P&gt;I want to&amp;nbsp;&lt;SPAN&gt;pass multiple column as argument to&lt;/SPAN&gt;&amp;nbsp;pivot a dataframe &lt;SPAN&gt;&amp;nbsp;in pyspark pivot like&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;mydf.groupBy(&lt;/SPAN&gt;&lt;SPAN&gt;"id"&lt;/SPAN&gt;&lt;SPAN&gt;).pivot(&lt;/SPAN&gt;&lt;SPAN&gt;"day"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;"city"&lt;/SPAN&gt;&lt;SPAN&gt;).agg(F.&lt;/SPAN&gt;&lt;SPAN&gt;sum&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;"price"&lt;/SPAN&gt;&lt;SPAN&gt;).alias(&lt;/SPAN&gt;&lt;SPAN&gt;"price"&lt;/SPAN&gt;&lt;SPAN&gt;),F.&lt;/SPAN&gt;&lt;SPAN&gt;sum&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;"units"&lt;/SPAN&gt;&lt;SPAN&gt;).alias(&lt;/SPAN&gt;&lt;SPAN&gt;"units"&lt;/SPAN&gt;&lt;SPAN&gt;)).show().&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;One way I found is to create multiple df with different pivot and join them which will result in multiple scan. But is there any other way to do this?&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 28 Nov 2023 11:50:43 GMT</pubDate>
      <guid>https://community.databricks.com/t5/get-started-discussions/pivot-on-multiple-columns/m-p/54092#M6190</guid>
      <dc:creator>memo</dc:creator>
      <dc:date>2023-11-28T11:50:43Z</dc:date>
    </item>
    <item>
      <title>Re: Pivot on multiple columns</title>
      <link>https://community.databricks.com/t5/get-started-discussions/pivot-on-multiple-columns/m-p/54166#M6192</link>
      <description>&lt;P&gt;Like how will the pass multiple values to the pivot function? It only takes one argument. I tried with sending an array, list. But it is throwing errors&lt;/P&gt;</description>
      <pubDate>Wed, 29 Nov 2023 08:33:26 GMT</pubDate>
      <guid>https://community.databricks.com/t5/get-started-discussions/pivot-on-multiple-columns/m-p/54166#M6192</guid>
      <dc:creator>memo</dc:creator>
      <dc:date>2023-11-29T08:33:26Z</dc:date>
    </item>
  </channel>
</rss>

