Skip to content

Commit 5e5bbeb

Browse files
committed
BUG: GH#15420 rank for categoricals
1 parent ef999c3 commit 5e5bbeb

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

pandas/tests/test_categorical.py

+8
Original file line numberDiff line numberDiff line change
@@ -4549,6 +4549,14 @@ def test_concat_categorical(self):
45494549
'h': [None] * 6 + cat_values})
45504550
tm.assert_frame_equal(res, exp)
45514551

4552+
def test_rank_categorical(self):
4553+
exp = pd.Series([1., 2., 3., 4., 5., 6.], name='A')
4554+
dframe = pd.DataFrame(['first', 'second', 'third', 'fourth', 'fifth', 'sixth'], columns=['A'])
4555+
dframe['A'] = dframe['A'].astype('category', ).cat.set_categories(
4556+
['first', 'second', 'third', 'fourth', 'fifth', 'sixth'], ordered=True)
4557+
res = dframe['A'].rank()
4558+
tm.assert_series_equal(res, exp)
4559+
45524560
class TestCategoricalSubclassing(tm.TestCase):
45534561

45544562
def test_constructor(self):

0 commit comments

Comments
 (0)