top_n¶
-
hhpy.ds.
top_n
(s: Sequence[T_co], n: Union[int, str], w: Optional[Sequence[T_co]] = None, n_max: int = 20) → list[source]¶ - Select n elements form a categorical pandas series with the highest counts. Ties are broken by sorting
- s ascending
Parameters: - s – pandas Series to select from
- n – how many elements to return, you can pass a percentage to return the top n %
- w – weights, if given the weights are summed instead of just counting entries in s [optional]
- n_max – how many elements to return at max if n is a percentage, set to None for no max [optional]
Returns: List of top n elements