Skip to content

ZeroDivisionError when groupby rank with method="dense" and pct=True #23864

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

Merged
merged 11 commits into from
Dec 3, 2018
Merged
Prev Previous commit
Next Next commit
Updated test case to assert expected result
  • Loading branch information
Koustav-Samaddar committed Nov 23, 2018
commit 7ce206cd8e224ae57b14fe92ee86da94c32a0cd6
6 changes: 4 additions & 2 deletions pandas/tests/groupby/test_rank.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,9 +294,11 @@ def test_rank_empty_group():

def test_rank_zero_div():
# GH 23666
df = pd.DataFrame({
df = DataFrame({
"A": [1, 2],
"B": [1, 1]
})

df.groupby("A")["B"].rank(pct=True, method="dense")
result = df.groupby("A").rank(pct=True, method="dense")
expected = DataFrame({"B": [1.0, 1.0]})
tm.assert_frame_equal(result, expected)