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

DEPR: Allowing grouping by an index label when there are duplicates #49434

Open
rhshadrach opened this issue Nov 1, 2022 · 0 comments
Open
Labels
Deprecate Functionality to remove in pandas Groupby

Comments

@rhshadrach
Copy link
Member

From #49373 (comment)

df = pd.DataFrame(
    {
        "a": [1, 1, 2],
        "b": [3, 4, 5],
    },
    index=pd.MultiIndex.from_tuples([(1, 1), (1, 2), (1, 3)], names=["f", "f"]),
)
gb = df.groupby("f")
result = gb.sum()
print(result)
#    a   b
# f       
# 1  4  12

There are two levels with the label "f" here; I think what the user wants in such a case is ambiguous. As such, we should raise instead of using the first level with the given label. In the similar case of grouping by columns, we currently raise.

@rhshadrach rhshadrach added Groupby Deprecate Functionality to remove in pandas labels Nov 1, 2022
@rhshadrach rhshadrach self-assigned this Jul 16, 2023
@rhshadrach rhshadrach removed their assignment Sep 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Deprecate Functionality to remove in pandas Groupby
Projects
None yet
Development

No branches or pull requests

1 participant