Skip to content

Commit

Permalink
Documentation cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
WillAyd committed Feb 8, 2018
1 parent f21ad2f commit 0141747
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 8 deletions.
25 changes: 23 additions & 2 deletions pandas/_libs/groupby_helper.pxi.in
Original file line number Diff line number Diff line change
Expand Up @@ -452,8 +452,29 @@ def group_rank_{{name}}(ndarray[float64_t, ndim=2] out,
ndarray[int64_t] labels,
bint is_datetimelike, object ties_method,
bint ascending, bint pct, object na_option):
"""
Only transforms on axis=0
"""Provides the rank of values within each group

Parameters
----------
out : array of float64_t values which this method will write its results to
values : array of {{c_type}} values to be ranked
labels : array containing unique label for each group, with its ordering
matching up to the corresponding record in `values`
is_datetimelike : bool
unused in this method but provided for call compatability with other
Cython transformations
ties_method : {'keep', 'top', 'bottom'}
* keep: leave NA values where they are
* top: smallest rank if ascending
* bottom: smallest rank if descending
ascending : boolean
False for ranks by high (1) to low (N)
pct : boolean
Compute percentage rank of data within each group

Notes
-----
This method modifies the `out` parameter rather than returning an object
"""
cdef:
TiebreakEnumType tiebreak
Expand Down
35 changes: 29 additions & 6 deletions pandas/core/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -1776,7 +1776,29 @@ def cumcount(self, ascending=True):
@Appender(_doc_template)
def rank(self, method='average', ascending=True, na_option='keep',
pct=False, axis=0):
"""Rank within each group"""
"""Provides the rank of values within each group
Parameters
----------
method : {'average', 'min', 'max', 'first', 'dense'}, efault 'average'
* average: average rank of group
* min: lowest rank in group
* max: highest rank in group
* first: ranks assigned in order they appear in the array
* dense: like 'min', but rank always increases by 1 between groups
method : {'keep', 'top', 'bottom'}, default 'keep'
* keep: leave NA values where they are
* top: smallest rank if ascending
* bottom: smallest rank if descending
ascending : boolean, default True
False for ranks by high (1) to low (N)
pct : boolean, default False
Compute percentage rank of data within each group
Returns
-----
DataFrame with ranking of values within each group
"""
return self._cython_transform('rank', numeric_only=False,
ties_method=method, ascending=ascending,
na_option=na_option, pct=pct, axis=axis)
Expand Down Expand Up @@ -2198,11 +2220,12 @@ def get_group_levels(self):
'cummax': 'group_cummax',
'rank': {
'name': 'group_rank',
'f': lambda func, a, b, c, d, **kwargs: func(a, b, c, d,
kwargs.get('ties_method', 'average'),
kwargs.get('ascending', True),
kwargs.get('pct', False),
kwargs.get('na_option', 'keep')
'f': lambda func, a, b, c, d, **kwargs: func(
a, b, c, d,
kwargs.get('ties_method', 'average'),
kwargs.get('ascending', True),
kwargs.get('pct', False),
kwargs.get('na_option', 'keep')
)
}
}
Expand Down

0 comments on commit 0141747

Please sign in to comment.