Skip to content

BUG: inconsistent groupby behavior when groupby.apply return dataframe #45066

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

Closed
2 of 3 tasks
GYHHAHA opened this issue Dec 25, 2021 · 2 comments
Closed
2 of 3 tasks

BUG: inconsistent groupby behavior when groupby.apply return dataframe #45066

GYHHAHA opened this issue Dec 25, 2021 · 2 comments
Labels
Bug Needs Triage Issue that has not been reviewed by a pandas team member

Comments

@GYHHAHA
Copy link
Contributor

GYHHAHA commented Dec 25, 2021

Pandas version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the master branch of pandas.

Reproducible Example

>>> df = pd.DataFrame({"A":[1,2,1,2]})
>>> df.groupby("A").apply(lambda x: x)
   A
0  1
1  2
2  1
3  2
>>> df.groupby("A").apply(lambda x: x.copy())
     A
A     
1 0  1
  2  1
2 1  2
  3  2

Issue Description

I think both two cases should return a multi-index (just like the second case). Is this actually a bug? or just on purpose?

Expected Behavior

>>> df = pd.DataFrame({"A":[1,2,1,2]})
>>> df.groupby("A").apply(lambda x: x)
     A
A     
1 0  1
  2  1
2 1  2
  3  2

Installed Versions

1.3.5

@GYHHAHA GYHHAHA added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Dec 25, 2021
@LucasG0
Copy link
Contributor

LucasG0 commented Dec 25, 2021

It looks like a duplicate of 44803

@GYHHAHA
Copy link
Contributor Author

GYHHAHA commented Dec 25, 2021

sorry for duplication, close

@GYHHAHA GYHHAHA closed this as completed Dec 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Needs Triage Issue that has not been reviewed by a pandas team member
Projects
None yet
Development

No branches or pull requests

2 participants