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

df.groupby on a column with complex numbers is broken #26475

Open
basnijholt opened this issue May 20, 2019 · 5 comments
Open

df.groupby on a column with complex numbers is broken #26475

basnijholt opened this issue May 20, 2019 · 5 comments
Assignees
Labels
Bug Complex Complex Numbers good first issue Groupby Needs Tests Unit test(s) needed to prevent regressions

Comments

@basnijholt
Copy link
Contributor

Currently, grouping by a key that has complex numbers is broken, see the following example

import pandas as pd
df = pd.DataFrame([dict(a=1, b=1 + 1j), dict(a=1, b=1 + 2j)])
df.groupby("b").groups

output:

{1.0: Int64Index([0, 1], dtype='int64')}

expected:

{0: Int64Index([0], dtype='int64'), 1: Int64Index([1], dtype='int64')}

Related #10921

@jschendel
Copy link
Member

Probably the same underlying issue as #17927

@jschendel jschendel added this to the Contributions Welcome milestone May 20, 2019
@mroeschke mroeschke removed this from the Contributions Welcome milestone Oct 13, 2022
@rhshadrach rhshadrach added the Needs Tests Unit test(s) needed to prevent regressions label Jul 15, 2023
@rhshadrach
Copy link
Member

I'm now seeing {(1+1j): [0], (1+2j): [1]} from the OP. Could likely use tests.

@xiaohuanlin
Copy link
Contributor

Hi @rhshadrach, can I take this question? I think the expection for this question is to create a unittest to prevent it happen again, is it right?

@aram-cinnamon
Copy link
Contributor

take

@aram-cinnamon
Copy link
Contributor

Ah sorry @xiaohuanlin, I already picked up this issue on Sunday (You can refer to our slack channel). Next time I'll take early so there's no confusion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Complex Complex Numbers good first issue Groupby Needs Tests Unit test(s) needed to prevent regressions
Projects
None yet
Development

No branches or pull requests

6 participants