DataFrame.nlargest(n, columns, keep='first')
[source]
Get the rows of a DataFrame sorted by the n
largest values of columns
.
New in version 0.17.0.
Parameters: |
n : int Number of items to retrieve columns : list or str Column name or names to order by keep : {‘first’, ‘last’, False}, default ‘first’ Where there are duplicate values: - |
---|---|
Returns: |
DataFrame |
>>> df = DataFrame({'a': [1, 10, 8, 11, -1], ... 'b': list('abdce'), ... 'c': [1.0, 2.0, np.nan, 3.0, 4.0]}) >>> df.nlargest(3, 'a') a b c 3 11 c 3 1 10 b 2 2 8 d NaN
© 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.19.2/generated/pandas.DataFrame.nlargest.html