[ 
https://issues.apache.org/jira/browse/SPARK-19428?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15851784#comment-15851784
 ] 

Luke Miner commented on SPARK-19428:
------------------------------------

Couple of things. Sometimes I just want a random row from each group. However, 
if sorting is allowed, then it is useful to get a single row from each group 
based on the maximum or minimum of some column. Even more useful would be 
something like

{{df.groupby('group').orderBy('foo').limit(n)}}

Then it would be easy to get the top {{n}} observations for each group based on 
some criteria.

> Ability to select first row of groupby
> --------------------------------------
>
>                 Key: SPARK-19428
>                 URL: https://issues.apache.org/jira/browse/SPARK-19428
>             Project: Spark
>          Issue Type: Brainstorming
>          Components: SQL
>    Affects Versions: 2.1.0
>            Reporter: Luke Miner
>            Priority: Minor
>
> It would be nice to be able to select the first row from {{GroupedData}}. 
> Pandas has something like this:
> {{df.groupby('group').first()}}
> It's especially handy if you can order the group as well.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org
For additional commands, e-mail: issues-h...@spark.apache.org

Reply via email to