Skip to content

Commit a7e573b

Browse files
committed
moved test for categorical, in rank, to top
1 parent 3ba4e3a commit a7e573b

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

pandas/core/algorithms.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -973,6 +973,10 @@ def _hashtable_algo(f, values, return_dtype=None):
973973
def _get_data_algo(values, func_map):
974974

975975
f = None
976+
977+
if is_categorical_dtype(values):
978+
values = values._values_for_rank()
979+
976980
if is_float_dtype(values):
977981
f = func_map['float64']
978982
values = _ensure_float64(values)
@@ -988,12 +992,6 @@ def _get_data_algo(values, func_map):
988992
elif is_unsigned_integer_dtype(values):
989993
f = func_map['uint64']
990994
values = _ensure_uint64(values)
991-
elif is_categorical_dtype(values):
992-
values = values._values_for_rank()
993-
if is_float_dtype(values):
994-
f = func_map['float64']
995-
else:
996-
f = func_map['object']
997995
else:
998996
values = _ensure_object(values)
999997

pandas/tests/series/test_analytics.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1059,7 +1059,7 @@ def test_rank(self):
10591059

10601060
def test_rank_categorical(self):
10611061
# GH issue #15420 rank incorrectly orders ordered categories
1062-
1062+
10631063
# Test ascending/descending ranking for ordered categoricals
10641064
exp = pd.Series([1., 2., 3., 4., 5., 6.])
10651065
exp_desc = pd.Series([6., 5., 4., 3., 2., 1.])

pandas/tests/test_categorical.py

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

4552+
45524553
class TestCategoricalSubclassing(tm.TestCase):
45534554

45544555
def test_constructor(self):

0 commit comments

Comments
 (0)