Get nsmallest values from a particular column in Pandas DataFrame (original) (raw)
Last Updated : 03 Oct, 2025
nsmallest() function returns the top n rows with the smallest values in the specified column(s).
Syntax:
DataFrame.nsmallest(n, columns, keep='first')
**Parameters:
- **n: Number of rows to return.
- **columns: Column label(s) to order by.
- **keep: Decides what to do if there are duplicate values:
****'first' (default):** keeps the first occurrence.
****'last':** keeps the last occurrence.
****'all':** keeps all occurrences.
To download the dataset used in this article, click here
Loading the Dataset
Python `
import pandas as pd df = pd.read_csv(r'enter the path to dataset here')
df.head(10)
`

**Explanation:
- **pd.read_csv(): loads the dataset as a pandas dataframe
- **df.head(10): prints the top 10 rows of the dataframe.
Example 1: Find the 5 Youngest Players (Smallest Ages)
Python `
df.nsmallest(5, ['Age'])
`
**Output

Example 2: Find the 10 Lightest Players (Smallest Weights)
Python `
df.nsmallest(10, ['Weight'])
`
**Output

Example 3: Getting the 5 smallest Rows by Age and Weight Together
Python `
df.nsmallest(5, ['Age', 'Weight'])
`
**Output
