Skip to content

Conversation

@ueshin
Copy link
Collaborator

@ueshin ueshin commented May 9, 2020

Fixing GroupBy.apply to follow complex group keys.

>>> kdf = ks.DataFrame({"a": [1, 2, 3, 4, 5, 6], "b": [1, 1, 2, 3, 5, 8], "c": [1, 4, 9, 16, 25, 36]})
>>> kdf.groupby(kdf.b // 5).apply(lambda x: x + x.min())
    a   b   c
0   2   2   2
1   3   2   5
2   6   4  18
3   8   6  32
4  10  10  50
5  12  16  72

This should be:

>>> pdf.groupby(pdf.b // 5).apply(lambda x: x + x.min())
    a   b   c
0   2   2   2
1   3   2   5
2   4   3  10
3   5   4  17
4  10  10  50
5  11  13  61

@ueshin ueshin requested a review from HyukjinKwon May 9, 2020 00:00
Copy link
Member

@HyukjinKwon HyukjinKwon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ueshin
Copy link
Collaborator Author

ueshin commented May 11, 2020

Thanks! I'd merge this now. I'll address the comment in the following PRs.

@ueshin ueshin merged commit d13a76f into databricks:master May 11, 2020
@ueshin ueshin deleted the groupby_apply branch May 11, 2020 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants