In this python pandas program, we will find the index of the smallest and largest value using pandas library.
Steps to solve the program
- Import pandas library as pd.
- Create a series using pd.Series().
- Find the index of the smallest and largest values using df.idxmin() and df.idxmax().
- 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