SeriesGroupBy.nlargest(*args, **kwargs) Return the largest n elements.
| Parameters: |
n : int Return this many descending sorted values keep : {‘first’, ‘last’, False}, default ‘first’ Where there are duplicate values: - take_last : deprecated |
|---|---|
| Returns: |
top_n : Series The n largest values in the Series, in sorted order |
See also
Series.nsmallest
Faster than .sort_values(ascending=False).head(n) for small n relative to the size of the Series object.
>>> import pandas as pd >>> import numpy as np >>> s = pd.Series(np.random.randn(1e6)) >>> s.nlargest(10) # only sorts up to the N requested
© 2011–2012 Lambda Foundry, Inc. and PyData Development Team
© 2008–2011 AQR Capital Management, LLC
© 2008–2014 the pandas development team
Licensed under the 3-clause BSD License.
http://pandas.pydata.org/pandas-docs/version/0.18.1/generated/pandas.core.groupby.SeriesGroupBy.nlargest.html