How can you find the minimum and maximum values present in a Pandas Series using Python?

Recently, I have been exploring different series statistics and how you can find them using Python, up till now I’ve found out about how you can calculate the minimum and maximum of a series using Pandas. The code I used is attached below:

The Minimum Value:

The Maximum Value:

Are there more ways of achieving the same results? If there are, please let me know along with a sample code for ease.

Yes, there are more ways to achieve this, you can use the np.min() and np.max() functions present in the NumPy library to get the minimum and maximum values of a series. Here is the example code for them:

The Minimum Value:

The Maximum Value:

Yes, there are more ways to do the same thing. You can use the nsmallest() and nlargest() methods which return the smallest and largest n values in the series. Since you want to find the first minimum and maximum value, you must specify n=1 in both these methods. Here is the code for it, which I hope will help you:

The Minimum Value:

The Maximum Value:

Yes, there are other methods and one of them is using the idxmin() and idxmax() functions which return the index of the minimum or maximum value in the series, you can then use this index to get the value. I have attached an example code below that uses this method:

The Minimum Value:

The Maximum Value: