Skip to content

Commit 9a6b5cd

Browse files
committed
BUG: GH15420 - _rank private method on Categorical
1 parent 4220e56 commit 9a6b5cd

File tree

1 file changed

+17
-24
lines changed

1 file changed

+17
-24
lines changed

pandas/core/algorithms.py

+17-24
Original file line numberDiff line numberDiff line change
@@ -598,35 +598,28 @@ def mode(values):
598598
def rank(values, axis=0, method='average', na_option='keep',
599599
ascending=True, pct=False):
600600
"""
601-
Compute numerical data ranks (1 through n) along axis. Equal values are
602-
assigned a rank that is the average of the ranks of those values
601+
Rank the values along a given axis.
603602
604603
Parameters
605604
----------
606-
axis : {0 or 'index', 1 or 'columns'}, default 0
607-
index to direct ranking
608-
method : {'average', 'min', 'max', 'first', 'dense'}
609-
* average: average rank of group
610-
* min: lowest rank in group
611-
* max: highest rank in group
612-
* first: ranks assigned in order they appear in the array
613-
* dense: like 'min', but rank always increases by 1 between groups
614-
numeric_only : boolean, default None
615-
Include only float, int, boolean data. Valid only for DataFrame or
616-
Panel objects
617-
na_option : {'keep', 'top', 'bottom'}
618-
* keep: leave NA values where they are
619-
* top: smallest rank if ascending
620-
* bottom: smallest rank if descending
605+
values : array-like
606+
Array whose values will be ranked. The number of dimensions in this
607+
array must not exceed 2.
608+
axis : int, default 0
609+
Axis over which to perform rankings.
610+
method : {'average', 'min', 'max', 'first', 'dense'}, default 'average'
611+
The method by which tiebreaks are broken during the ranking.
612+
na_option : {'keep', 'top'}, default 'keep'
613+
The method by which NaNs are placed in the ranking.
614+
- ``keep``: rank each NaN value with a NaN ranking
615+
- ``top``: replace each NaN with either +/- inf so that they
616+
there are ranked at the top
621617
ascending : boolean, default True
622-
False for ranks by high (1) to low (N)
618+
Whether or not the elements should be ranked in ascending order.
623619
pct : boolean, default False
624-
Computes percentage rank of data
625-
626-
Returns
627-
-------
628-
ranks : same type as caller
629-
"""
620+
Whether or not to the display the returned rankings in integer form
621+
(e.g. 1, 2, 3) or in percentile form (e.g. 0.333..., 0.666..., 1).
622+
"""
630623
if is_categorical(values):
631624
ranks = values._rank(axis=axis, method=method, ascending=ascending,
632625
na_option=na_option, pct=pct)

0 commit comments

Comments
 (0)