<?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 Trying to use pivot function with pyspark for count aggregate in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/trying-to-use-pivot-function-with-pyspark-for-count-aggregate/m-p/50758#M28887</link>
    <description>&lt;P&gt;I'm trying this code but getting the following error&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;testDF = (eventsDF
          .groupBy("user_id")
          .pivot("event_name")
          .count("event_name"))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;TypeError&lt;/SPAN&gt;&lt;SPAN&gt;: _api() takes 1 positional argument but 2 were given&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Please guide how to fix the error&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 09 Nov 2023 20:46:48 GMT</pubDate>
    <dc:creator>rbricks007</dc:creator>
    <dc:date>2023-11-09T20:46:48Z</dc:date>
    <item>
      <title>Trying to use pivot function with pyspark for count aggregate</title>
      <link>https://community.databricks.com/t5/data-engineering/trying-to-use-pivot-function-with-pyspark-for-count-aggregate/m-p/50758#M28887</link>
      <description>&lt;P&gt;I'm trying this code but getting the following error&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;testDF = (eventsDF
          .groupBy("user_id")
          .pivot("event_name")
          .count("event_name"))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;TypeError&lt;/SPAN&gt;&lt;SPAN&gt;: _api() takes 1 positional argument but 2 were given&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Please guide how to fix the error&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2023 20:46:48 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/trying-to-use-pivot-function-with-pyspark-for-count-aggregate/m-p/50758#M28887</guid>
      <dc:creator>rbricks007</dc:creator>
      <dc:date>2023-11-09T20:46:48Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to use pivot function with pyspark for count aggregate</title>
      <link>https://community.databricks.com/t5/data-engineering/trying-to-use-pivot-function-with-pyspark-for-count-aggregate/m-p/50827#M28907</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;from pyspark.sql import functions as F
testDF = (eventsDF
            .groupBy("user_id")
            .pivot("event_name")
            .agg(F.count("event_name")))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Nov 2023 17:08:39 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/trying-to-use-pivot-function-with-pyspark-for-count-aggregate/m-p/50827#M28907</guid>
      <dc:creator>Krishnamatta</dc:creator>
      <dc:date>2023-11-10T17:08:39Z</dc:date>
    </item>
  </channel>
</rss>

