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

[BUG] Index of empty objects not set in Groupby.apply #13939

Closed
galipremsagar opened this issue Aug 23, 2023 · 0 comments · Fixed by #13944
Closed

[BUG] Index of empty objects not set in Groupby.apply #13939

galipremsagar opened this issue Aug 23, 2023 · 0 comments · Fixed by #13944
Assignees
Labels
bug Something isn't working Python Affects Python cuDF API.

Comments

@galipremsagar
Copy link
Contributor

Describe the bug
When Groupby.apply is invoked on objects that are empty, their .index objects aren't being set to the grouping keys.

Steps/Code to reproduce bug

In [1]: import pandas as pd

In [2]: import cudf

In [3]: df = cudf.DataFrame({"a": [], "b": [], "c": []}, dtype='datetime64[ns]')
df
In [4]: gb = df.groupby("a")['b']

In [7]: pg = df.to_pandas().groupby("a")['b']

In [9]: pg.apply("idxmin").index
Out[9]: DatetimeIndex([], dtype='datetime64[ns]', name='a', freq=None)

In [10]: pg.apply("idxmin")
Out[10]: Series([], Name: b, dtype: datetime64[ns])

In [11]: gb.apply("idxmin")
Out[11]: Series([], Name: b, dtype: datetime64[ns])

In [12]: gb.apply("idxmin").index
Out[12]: RangeIndex(start=0, stop=0, step=1)

Expected behavior

In [12]: gb.apply("idxmin").index
Out[12]: DatetimeIndex([], dtype='datetime64[ns]', name='a', freq=None)

Environment overview (please complete the following information)

  • Environment location: [Bare-metal]
  • Method of cuDF install: [from source]
@galipremsagar galipremsagar added bug Something isn't working Python Affects Python cuDF API. labels Aug 23, 2023
@galipremsagar galipremsagar self-assigned this Aug 23, 2023
rapids-bot bot pushed a commit that referenced this issue Aug 23, 2023
…objects (#13944)

closes #13939 
This PR fixes two issues with `Groupby.apply`, where the index of the result was not being set correctly and there is a corner case for `bool` dtype that has to be handled for `sum` & `product` operations.

Authors:
  - GALI PREM SAGAR (https://github.com/galipremsagar)

Approvers:
  - Bradley Dice (https://github.com/bdice)

URL: #13944
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Python Affects Python cuDF API.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant