Python Practice › Pandas Programs › Program 28

Index of smallest and largest

EasyPandas Programs · 28 of 95

Write a pandas program to find the index of the smallest and largest values.

Advertisement
Input
[54, 25, 38, 87]
Output
1 3

Approach

  1. idxmin() and idxmax().

Solution

Python
import pandas as pds = pd.Series([54, 25, 38, 87])print(s.idxmin(), s.idxmax())
Output
1 3
Advertisement

Learn the concept

New to this topic? Read the lesson, then come back.

More pandas programs

← All 95 Pandas Programs