Skip to content

BUG: groupby(axis=0).rank(axis=1) #41320

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
jbrockmendel opened this issue May 4, 2021 · 0 comments · Fixed by #41324
Closed

BUG: groupby(axis=0).rank(axis=1) #41320

jbrockmendel opened this issue May 4, 2021 · 0 comments · Fixed by #41324
Labels
Algos Non-arithmetic algos: value_counts, factorize, sorting, isin, clip, shift, diff Bug
Milestone

Comments

@jbrockmendel
Copy link
Member

Looks like it is discarding the axis=1

df = DataFrame({0: [1, 3, 5, 7], 1: [2, 4, 6, 8], 2: [1.5, 3.5, 5.5, 7.5]}, index=["a", "a", "b", "b"])
gb = df.groupby(level=0, axis=0)

res = gb.rank(axis=1)

# This should match what we get when "manually" operating group-by-group
expected = concat([df.loc["a"].rank(axis=1), df.loc["b"].rank(axis=1)], axis=0)

>>> res
     0    1    2
a  1.0  1.0  1.0
a  2.0  2.0  2.0
b  1.0  1.0  1.0
b  2.0  2.0  2.0


>>> expected
     0    1    2
a  1.0  3.0  2.0
a  1.0  3.0  2.0
b  1.0  3.0  2.0
b  1.0  3.0  2.0
@jbrockmendel jbrockmendel added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels May 4, 2021
@jreback jreback added this to the 1.3 milestone May 5, 2021
@jreback jreback added Algos Non-arithmetic algos: value_counts, factorize, sorting, isin, clip, shift, diff and removed Needs Triage Issue that has not been reviewed by a pandas team member labels May 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Algos Non-arithmetic algos: value_counts, factorize, sorting, isin, clip, shift, diff Bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants