Python Practice › Pandas Programs › Program 59
Row with the minimum value
Write a pandas program to find the row where a column is smallest.
Output
name Alex salary 50000 Name: 0, dtype: object
Approach
idxmin().
Solution
import pandas as pddf = pd.DataFrame({"name": ["Alex", "John", "Peter", "Klaus"], "salary": [50000, 65000, 63000, 59000]})print(df.loc[df["salary"].idxmin()])Output
name Alex salary 50000 Name: 0, dtype: object
Learn the concept
New to this topic? Read the lesson, then come back.