Pandas DataFrame: nlargest() function
DataFrame - nlargest() function
The nlargest() function is used to get the first n rows ordered by columns in descending order. The columns that are not specified are returned as well, but not used for ordering.
Syntax:
DataFrame.nlargest(self, n, columns, keep='first')
Parameters:
Name | Description | Type/Default Value | Required / Optional |
---|---|---|---|
n | Number of rows to return. | int | Required |
columns | Column label(s) to order by. | label or list of labels | Required |
keep | Where there are duplicate values:
|
{‘first’, ‘last’, ‘all’} Default Value: ‘first’ |
Required |
Returns:DataFrame
The first n rows ordered by the given columns in descending order.
Example:
Download the Pandas DataFrame Notebooks from here.
Previous: DataFrame - sort_values() function
Next: DataFrame - nsmallest() function
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://w3resource.com/pandas/dataframe/dataframe-nlargest.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics