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
- Exercises: Weekly Top 12 Most Popular Topics
- Pandas DataFrame: Exercises, Practice, Solution
- Conversion Tools
- JavaScript: HTML Form Validation
- SQL Exercises, Practice, Solution - SUBQUERIES
- C Programming Exercises, Practice, Solution : For Loop
- Python Exercises, Practice, Solution
- Python Data Type: List - Exercises, Practice, Solution
- C++ Basic: Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - exercises on Employee Database
- SQL Exercises, Practice, Solution - exercises on Movie Database
- SQL Exercises, Practice, Solution - exercises on Soccer Database
- C Programming Exercises, Practice, Solution : Recursion