<?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: agg function not working for multiple aggregations in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/agg-function-not-working-for-multiple-aggregations/m-p/30315#M21959</link>
    <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Hi Francis,&lt;/P&gt;
&lt;P&gt;Thanks for reaching out.&lt;/P&gt;
&lt;P&gt;I just tried this in version 2.0 of Databricks and it appeared to work as expected.&lt;/P&gt;
&lt;P&gt;Are you using version 2.0 and Spark 1.4?&lt;/P&gt;
&lt;P&gt;If so I would suggest using this alternate syntax:&lt;/P&gt;from pyspark.sql import functions as F
&lt;P&gt;&lt;/P&gt; 
&lt;P&gt;aggs = df.groupBy("cut").agg(df.cut, F.min("carat"), F.max("carat"), F.avg("carat")) &lt;/P&gt;
&lt;P&gt;Let me know if that works for you.&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 25 Aug 2015 14:11:17 GMT</pubDate>
    <dc:creator>rlgarris</dc:creator>
    <dc:date>2015-08-25T14:11:17Z</dc:date>
    <item>
      <title>agg function not working for multiple aggregations</title>
      <link>https://community.databricks.com/t5/data-engineering/agg-function-not-working-for-multiple-aggregations/m-p/30314#M21958</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;B&gt;Data has 2 columns:&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;|requestDate|requestDuration| &lt;/P&gt;
&lt;P&gt;| 2015-06-17| 104| &lt;/P&gt;
&lt;P&gt;&lt;B&gt;Here is the code:&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;avgSaveTimesByDate = gridSaves.groupBy(gridSaves.requestDate).agg({"requestDuration": "min", "requestDuration": "max","requestDuration": "avg"}) &lt;/P&gt;
&lt;P&gt;avgSaveTimesByDate.show(100)&lt;/P&gt;
&lt;P&gt;&lt;B&gt;Summary of Issue&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;I expect 4 columns of data: date, min, max and average but only the date and average shows. The first 2 aggs do not show up. If I move max to the last position, only date and max shows up. Very weird. &lt;/P&gt;
&lt;P&gt;+-----------+--------------------+ |requestDate|AVG(requestDuration)| +-----------+--------------------+ &lt;/P&gt;
&lt;P&gt;| 2015-06-10| 750.8886326991035|&lt;/P&gt;
&lt;P&gt;Am I doing this incorrectly? I am trying to get a dataframe for a box plot. &lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jul 2015 03:58:10 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/agg-function-not-working-for-multiple-aggregations/m-p/30314#M21958</guid>
      <dc:creator>FrancisLau</dc:creator>
      <dc:date>2015-07-31T03:58:10Z</dc:date>
    </item>
    <item>
      <title>Re: agg function not working for multiple aggregations</title>
      <link>https://community.databricks.com/t5/data-engineering/agg-function-not-working-for-multiple-aggregations/m-p/30315#M21959</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Hi Francis,&lt;/P&gt;
&lt;P&gt;Thanks for reaching out.&lt;/P&gt;
&lt;P&gt;I just tried this in version 2.0 of Databricks and it appeared to work as expected.&lt;/P&gt;
&lt;P&gt;Are you using version 2.0 and Spark 1.4?&lt;/P&gt;
&lt;P&gt;If so I would suggest using this alternate syntax:&lt;/P&gt;from pyspark.sql import functions as F
&lt;P&gt;&lt;/P&gt; 
&lt;P&gt;aggs = df.groupBy("cut").agg(df.cut, F.min("carat"), F.max("carat"), F.avg("carat")) &lt;/P&gt;
&lt;P&gt;Let me know if that works for you.&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Aug 2015 14:11:17 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/agg-function-not-working-for-multiple-aggregations/m-p/30315#M21959</guid>
      <dc:creator>rlgarris</dc:creator>
      <dc:date>2015-08-25T14:11:17Z</dc:date>
    </item>
    <item>
      <title>Re: agg function not working for multiple aggregations</title>
      <link>https://community.databricks.com/t5/data-engineering/agg-function-not-working-for-multiple-aggregations/m-p/30316#M21960</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;My guess is that the reason this may not work is the fact that the dictionary input does not have unique keys. With this syntax, column-names are keys and if you have two or more aggregation for the same column, some internal loops may forget the non-uniqueness of the keys.&lt;/P&gt; 
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 12 Nov 2016 20:41:47 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/agg-function-not-working-for-multiple-aggregations/m-p/30316#M21960</guid>
      <dc:creator>ReKa</dc:creator>
      <dc:date>2016-11-12T20:41:47Z</dc:date>
    </item>
  </channel>
</rss>

