This thread is part 1 of 2 which will be focused on calculating different statistical values of a series using different alternative methods for each statistic. Firstly, if you are unfamiliar with series objects or you want to learn more about them, have a look at the following threads:
- Building Pandas series with several datatypes.
- Filtering out values from a series.
- Finding unique elements in two series.
- Assign a series’ index a name.
The following statistical calculations of a series will be covered in this thread:
- Minimum Value
- Maximum Value
However, if you want to learn more series statistics, then have a look at the second part of this thread: Calculating series statistics part 2.
The minimum value
1. Using 'min()' method:
- The
min()
method of a Pandas series returns the minimum value in the series.
2. Using 'nsmallest()' method:
- The
nsmallest()
method returns the smallestn
values in the series. To find the first minimum value, we can usen=1
.
3. Using 'idxmin()' method:
- The
idxmin()
method returns the index of the minimum value in the series.
4. Using 'np.min()' method:
- The
np.min()
is a NumPy function that is used to find the minimum value from a collection of values.
The maximum value
1. Using 'max()' method:
- The
max()
method of a Pandas series returns the maximum value in the series.
2. Using 'nlargest()' method:
- The
nlargest()
method returns the largestn
values in the series. To find the first maximum value, we can usen=1
.
3. Using 'idxmax()' method:
- The
idxmax()
method returns the index of the maximum value in the series.
4. Using 'np.max()' method:
- The
np.max()
is a NumPy function that is used to find the maximum value from a collection of values.