MCPcopy
hub / github.com/pandas-dev/pandas / ranker

Method ranker

pandas/core/generic.py:9542–9569  ·  view source on GitHub ↗
(data)

Source from the content-addressed store, hash-verified

9540 raise ValueError(msg)
9541
9542 def ranker(data):
9543 if data.ndim == 2:
9544 # i.e. DataFrame, we cast to ndarray
9545 values = data.values
9546 else:
9547 # i.e. Series, can dispatch to EA
9548 values = data._values
9549
9550 if isinstance(values, ExtensionArray):
9551 ranks = values._rank(
9552 axis=axis_int,
9553 method=method,
9554 ascending=ascending,
9555 na_option=na_option,
9556 pct=pct,
9557 )
9558 else:
9559 ranks = algos.rank(
9560 values,
9561 axis=axis_int,
9562 method=method,
9563 ascending=ascending,
9564 na_option=na_option,
9565 pct=pct,
9566 )
9567
9568 ranks_obj = self._constructor(ranks, **data._construct_axes_dict())
9569 return ranks_obj.__finalize__(self, method="rank")
9570
9571 if numeric_only:
9572 if self.ndim == 1 and not is_numeric_dtype(self.dtype):

Callers

nothing calls this directly

Calls 5

_constructorMethod · 0.95
_construct_axes_dictMethod · 0.80
__finalize__Method · 0.80
_rankMethod · 0.45
rankMethod · 0.45

Tested by

no test coverage detected