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

koert kuipers edited comment on SPARK-19428 at 2/4/17 6:10 PM:
---------------------------------------------------------------

getting a first element for each group (which is somewhat ill defined if the 
group is not sorted), or a single row from each group based on the maximum or 
minimum of some column, can be easily done with an aggregator.

what is wrong with:
{noformat}
df.groupBy("group").agg(first("somecolumn"))
{noformat}

it wouldn't be hard to write an aggregator that takes some sorting into account 
as well to select first element sorted.


was (Author: koert):
getting a first element for each group (which is somewhat ill defined if the 
group is not sorted), or a single row from each group based on the maximum or 
minimum of some column, can be easily done with an aggregator.

what is wrong with:
df.groupBy("group").agg(first("somecolumn"))

it wouldn't be hard to write an aggregator that takes some sorting into account 
as well to select first element sorted.

> 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: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to