Skip to content

Commit 201d29b

Browse files
committed
do dispatch inside algos.rank
1 parent 529824f commit 201d29b

File tree

2 files changed

+18
-17
lines changed

2 files changed

+18
-17
lines changed

pandas/core/algorithms.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,6 +1015,16 @@ def rank(
10151015
Whether or not to the display the returned rankings in integer form
10161016
(e.g. 1, 2, 3) or in percentile form (e.g. 0.333..., 0.666..., 1).
10171017
"""
1018+
if not isinstance(values, np.ndarray):
1019+
# i.e. ExtensionArray
1020+
return values._rank(
1021+
axis=axis,
1022+
method=method,
1023+
ascending=ascending,
1024+
na_option=na_option,
1025+
pct=pct,
1026+
)
1027+
10181028
is_datetimelike = needs_i8_conversion(values.dtype)
10191029
values = _get_values_for_rank(values)
10201030
if values.ndim == 1:

pandas/core/generic.py

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8501,23 +8501,14 @@ def ranker(data):
85018501
# i.e. Series, can dispatch to EA
85028502
values = data._values
85038503

8504-
if isinstance(values, ExtensionArray):
8505-
ranks = values._rank(
8506-
axis=axis,
8507-
method=method,
8508-
ascending=ascending,
8509-
na_option=na_option,
8510-
pct=pct,
8511-
)
8512-
else:
8513-
ranks = algos.rank(
8514-
values,
8515-
axis=axis,
8516-
method=method,
8517-
ascending=ascending,
8518-
na_option=na_option,
8519-
pct=pct,
8520-
)
8504+
ranks = algos.rank(
8505+
values,
8506+
axis=axis,
8507+
method=method,
8508+
ascending=ascending,
8509+
na_option=na_option,
8510+
pct=pct,
8511+
)
85218512

85228513
ranks_obj = self._constructor(ranks, **data._construct_axes_dict())
85238514
return ranks_obj.__finalize__(self, method="rank")

0 commit comments

Comments
 (0)