[
https://issues.apache.org/jira/browse/SPARK-19428?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15852867#comment-15852867
]
Luke Miner commented on SPARK-19428:
------------------------------------
Unfortunately no, because that would just get me a row for a single group. If I
have thousands of groups that means I have to iterate a ton of times and then
append the results.
A use case that is very common for me is if I have panel data of many
individuals spending over time and I want to get the most recent observation in
time for each person. Then I'd like to be able to do something like.
{{df_recent_obs = df.groupBy('individual_id').orderBy('timestamp',
ascending=False).limit(1)}}
> 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]