Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support callable instances to apply as a function, and fix groupby.apply to keep the index when possible #1686

Merged
merged 2 commits into from
Jul 31, 2020

Conversation

HyukjinKwon
Copy link
Member

This PR fixes two things.

  1. Support Callable instances that are not functions:

    from databricks import koalas as ks
    ks.DataFrame({'a': [-1, -2, 3, 4]}).apply(abs)
       a
    0  1
    1  2
    2  3
    3  4
    
  2. Keep index name when DataFrameGroupBy returns a Series:

    from databricks import koalas as ks
    ks.DataFrame({'a': [1, 2, 2, 2], 'b': [1, 2, 3, 4]}).groupby("a").apply(len)
    a
    1    1
    2    3
    Name: 0, dtype: int64
    

Resolves #1684

databricks/koalas/frame.py Outdated Show resolved Hide resolved
@itholic
Copy link
Contributor

itholic commented Jul 30, 2020

LGTM except several nit suggestions.

Copy link
Collaborator

@ueshin ueshin left a comment

Choose a reason for hiding this comment

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

I left some comments, and I agree with @itholic's suggestion.
Otherwise, LGTM.

databricks/koalas/tests/test_groupby.py Show resolved Hide resolved
databricks/koalas/tests/test_groupby.py Show resolved Hide resolved
databricks/koalas/tests/test_groupby.py Show resolved Hide resolved
databricks/koalas/tests/test_groupby.py Show resolved Hide resolved
databricks/koalas/groupby.py Show resolved Hide resolved
@HyukjinKwon
Copy link
Member Author

Merged. Thanks guys for reviewing it.

@HyukjinKwon HyukjinKwon merged commit b5aacc7 into databricks:master Jul 31, 2020
@HyukjinKwon HyukjinKwon deleted the built-in-apply branch September 11, 2020 07:50
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.

ValueError: no signature found for builtin type <class 'dict'> when trying to create object column with dicts
3 participants