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
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework