Skip to content

Commit

Permalink
test for non-ordered Categorical rank
Browse files Browse the repository at this point in the history
  • Loading branch information
jbrockmendel committed Jan 30, 2023
1 parent 31bef27 commit d331b99
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions pandas/tests/groupby/test_rank.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,23 @@
import pandas._testing as tm


def test_rank_unordered_categorical_typeerror():
# GH#51034 should be TypeError, not NotImplementedError
cat = pd.Categorical([], ordered=False)
ser = Series(cat)
df = ser.to_frame()

msg = "Cannot perform rank with non-ordered Categorical"

gb = ser.groupby(cat)
with pytest.raises(TypeError, match=msg):
gb.rank()

gb2 = df.groupby(cat)
with pytest.raises(TypeError, match=msg):
gb2.rank()


def test_rank_apply():
lev1 = tm.rands_array(10, 100)
lev2 = tm.rands_array(10, 130)
Expand Down

0 comments on commit d331b99

Please sign in to comment.