Find the index of the smallest and largest value using Pandas

In this python pandas program, we will find the index of the smallest and largest value using pandas library.

Steps to solve the program
  1. Import pandas library as pd.
  2. Create a series using pd.Series().
  3. Find the index of the smallest and largest values using df.idxmin() and df.idxmax().
  4. Print the output.
				
					import pandas as pd
df = pd.Series([54,25,38,87,67])
print(df)
print("Index of the first smallest and largest value of the series:")
print(df.idxmin())
print(df.idxmax())
				
			

Output :

				
					0    54
1    25
2    38
3    87
4    67
dtype: int64
Index of the first smallest and largest value of the series:
1
3
				
			

convert a dictionary into DataFrame

Leave a Comment