Pandas DataFrame is two-dimensional size-mutable, potentially heterogeneous tabular data structure with labeled axes (rows and columns).
Let’s see how can we can get n-largest values from a particular column in Pandas DataFrame.
Observe this dataset first. We’ll use ‘Age’, ‘Weight’ and ‘Salary’ columns of this data in order to get n-largest values from a particular column in Pandas DataFrame.
import pandas as pd
df.head(10)
Code #1: Getting 5 largest Age
import pandas as pd
df = pd.read_csv("nba.csv")
df.nlargest(5, ['Age'])
Output:
Code #2: Getting 10 maximum weights
import pandas as pd
df = pd.read_csv("nba.csv")
df.nlargest(10, ['Weight'])
Output:
Code #3: Getting 10 maximum salary
import pandas as pd
df = pd.read_csv("nba.csv")
df.nlargest(5, ['Salary'])
Output:
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
18 Dec, 2018
Like Article
Save Article