diff --git a/pandas/_libs/algos.pyx b/pandas/_libs/algos.pyx index c2d6a3bc4906d..7a2fc9dc7845a 100644 --- a/pandas/_libs/algos.pyx +++ b/pandas/_libs/algos.pyx @@ -49,8 +49,9 @@ cdef inline bint are_diff(object left, object right): class Infinity: - """ provide a positive Infinity comparison method for ranking """ - + """ + Provide a positive Infinity comparison method for ranking. + """ __lt__ = lambda self, other: False __le__ = lambda self, other: isinstance(other, Infinity) __eq__ = lambda self, other: isinstance(other, Infinity) @@ -61,8 +62,9 @@ class Infinity: class NegInfinity: - """ provide a negative Infinity comparison method for ranking """ - + """ + Provide a negative Infinity comparison method for ranking. + """ __lt__ = lambda self, other: (not isinstance(other, NegInfinity) and not missing.checknull(other)) __le__ = lambda self, other: not missing.checknull(other) @@ -158,20 +160,19 @@ def groupsort_indexer(const int64_t[:] index, Py_ssize_t ngroups): Parameters ---------- index: int64 ndarray - mappings from group -> position + Mappings from group -> position. ngroups: int64 - number of groups + Number of groups. Returns ------- tuple - 1-d indexer ordered by groups, group counts + 1-d indexer ordered by groups, group counts. Notes ----- This is a reverse of the label factorization process. """ - cdef: Py_ssize_t i, loc, label, n ndarray[int64_t] counts, where, result @@ -679,7 +680,9 @@ def is_monotonic(ndarray[algos_t, ndim=1] arr, bint timelike): Returns ------- tuple - is_monotonic_inc, is_monotonic_dec, is_unique + is_monotonic_inc : bool + is_monotonic_dec : bool + is_unique : bool """ cdef: Py_ssize_t i, n @@ -774,9 +777,8 @@ ctypedef fused rank_t: def rank_1d(rank_t[:] in_arr, ties_method='average', ascending=True, na_option='keep', pct=False): """ - Fast NaN-friendly version of scipy.stats.rankdata + Fast NaN-friendly version of ``scipy.stats.rankdata``. """ - cdef: Py_ssize_t i, j, n, dups = 0, total_tie_count = 0, non_na_idx = 0 @@ -995,9 +997,8 @@ def rank_1d(rank_t[:] in_arr, ties_method='average', def rank_2d(rank_t[:, :] in_arr, axis=0, ties_method='average', ascending=True, na_option='keep', pct=False): """ - Fast NaN-friendly version of scipy.stats.rankdata + Fast NaN-friendly version of ``scipy.stats.rankdata``. """ - cdef: Py_ssize_t i, j, z, k, n, dups = 0, total_tie_count = 0