Skip to content

Commit 0141747

Browse files
committed
Documentation cleanup
1 parent f21ad2f commit 0141747

File tree

2 files changed

+52
-8
lines changed

2 files changed

+52
-8
lines changed

pandas/_libs/groupby_helper.pxi.in

+23-2
Original file line numberDiff line numberDiff line change
@@ -452,8 +452,29 @@ def group_rank_{{name}}(ndarray[float64_t, ndim=2] out,
452452
ndarray[int64_t] labels,
453453
bint is_datetimelike, object ties_method,
454454
bint ascending, bint pct, object na_option):
455-
"""
456-
Only transforms on axis=0
455+
"""Provides the rank of values within each group
456+
457+
Parameters
458+
----------
459+
out : array of float64_t values which this method will write its results to
460+
values : array of {{c_type}} values to be ranked
461+
labels : array containing unique label for each group, with its ordering
462+
matching up to the corresponding record in `values`
463+
is_datetimelike : bool
464+
unused in this method but provided for call compatability with other
465+
Cython transformations
466+
ties_method : {'keep', 'top', 'bottom'}
467+
* keep: leave NA values where they are
468+
* top: smallest rank if ascending
469+
* bottom: smallest rank if descending
470+
ascending : boolean
471+
False for ranks by high (1) to low (N)
472+
pct : boolean
473+
Compute percentage rank of data within each group
474+
475+
Notes
476+
-----
477+
This method modifies the `out` parameter rather than returning an object
457478
"""
458479
cdef:
459480
TiebreakEnumType tiebreak

pandas/core/groupby.py

+29-6
Original file line numberDiff line numberDiff line change
@@ -1776,7 +1776,29 @@ def cumcount(self, ascending=True):
17761776
@Appender(_doc_template)
17771777
def rank(self, method='average', ascending=True, na_option='keep',
17781778
pct=False, axis=0):
1779-
"""Rank within each group"""
1779+
"""Provides the rank of values within each group
1780+
1781+
Parameters
1782+
----------
1783+
method : {'average', 'min', 'max', 'first', 'dense'}, efault 'average'
1784+
* average: average rank of group
1785+
* min: lowest rank in group
1786+
* max: highest rank in group
1787+
* first: ranks assigned in order they appear in the array
1788+
* dense: like 'min', but rank always increases by 1 between groups
1789+
method : {'keep', 'top', 'bottom'}, default 'keep'
1790+
* keep: leave NA values where they are
1791+
* top: smallest rank if ascending
1792+
* bottom: smallest rank if descending
1793+
ascending : boolean, default True
1794+
False for ranks by high (1) to low (N)
1795+
pct : boolean, default False
1796+
Compute percentage rank of data within each group
1797+
1798+
Returns
1799+
-----
1800+
DataFrame with ranking of values within each group
1801+
"""
17801802
return self._cython_transform('rank', numeric_only=False,
17811803
ties_method=method, ascending=ascending,
17821804
na_option=na_option, pct=pct, axis=axis)
@@ -2198,11 +2220,12 @@ def get_group_levels(self):
21982220
'cummax': 'group_cummax',
21992221
'rank': {
22002222
'name': 'group_rank',
2201-
'f': lambda func, a, b, c, d, **kwargs: func(a, b, c, d,
2202-
kwargs.get('ties_method', 'average'),
2203-
kwargs.get('ascending', True),
2204-
kwargs.get('pct', False),
2205-
kwargs.get('na_option', 'keep')
2223+
'f': lambda func, a, b, c, d, **kwargs: func(
2224+
a, b, c, d,
2225+
kwargs.get('ties_method', 'average'),
2226+
kwargs.get('ascending', True),
2227+
kwargs.get('pct', False),
2228+
kwargs.get('na_option', 'keep')
22062229
)
22072230
}
22082231
}

0 commit comments

Comments
 (0)