Skip to content

Commit ce90207

Browse files
committed
BUG: GH#15420 rank for categoricals
1 parent 85b267a commit ce90207

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

pandas/tests/test_categorical.py

+7
Original file line numberDiff line numberDiff line change
@@ -4549,6 +4549,13 @@ 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)
45524559

45534560
class TestCategoricalSubclassing(tm.TestCase):
45544561

0 commit comments

Comments
 (0)