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

GroupBy.idxmin and idxmax are very broken #584

Open
phofl opened this issue Dec 18, 2023 · 0 comments
Open

GroupBy.idxmin and idxmax are very broken #584

phofl opened this issue Dec 18, 2023 · 0 comments
Milestone

Comments

@phofl
Copy link
Collaborator

phofl commented Dec 18, 2023

The implementation is broken as soon as the max or min value is not in the first partition

This was broken for years, so only adding for API compatibility now but we should fix this

def test_df_groupby_idxmax():
    pdf = pd.DataFrame(
        {"idx": list(range(4)), "group": [1, 1, 2, 2, 1], "value": [10, 20, 20, 10, 40]}
    ).set_index("idx")

    ddf = dd.from_pandas(pdf, npartitions=3)

    expected = pd.DataFrame({"group": [1, 2], "value": [4, 2]}).set_index("group")

    result_pd = pdf.groupby("group").idxmax()
    result_dd = ddf.groupby("group").idxmax()

    assert_eq(result_pd, result_dd)
    assert_eq(expected, result_dd)

This is a very simple reproducer for the underlying issue

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

No branches or pull requests

1 participant