Calculating Series Statistics Part 2

This thread is part 2 of the threads which are focused on calculating different series statistics using different methods. If you wanna have a look at the first thread and want to learn those statistics, you can visit that thread from here: Calculating series statistics pt.1.

This thread will cover the following statistics of a series:

  1. Median Value.
  2. 25th Percentile Value.
  3. 75th Percentile Value.

The Median Value

1. Using 'median()' method:

  • The median() method of a Pandas series returns the median value of the series.

2. Using 'quantile()' method:

  • The quantile() method returns the value at the given quantile of the series. To find the median value, we can use q=0.5.
  • In statistics, a quantile is a value that divides a data distribution into intervals of equal probability, and they are useful for summarizing the distribution of a dataset.
  • Specifying q = 0.5 means the value which divides the data into two equal parts, hence this is how we get the median value.

3. Using 'np.median()' method:

  • The np.median() is a NumPy function that can be used to calculate the median of a Pandas series.

The 25th and 75th Percentile Values

  • 25th percentile is also known as the first quartile, and it is a statistical measure that indicates the value below which 25% of the data lies.
  • 75th percentile is also known as the third quartile, and it is a statistical measure that indicates the value below which 75% of the data lies.

1. Using 'np.percentile()' method:

  • The np.percentile() function computes the nth percentile of a given data set. To find the 25th and 75th percentiles of a series, we can use this function and pass 25 and 75 as the percentile value.
  • We can also pass a list of percentile values we want.

2. Using 'quantile()' method:

  • The quantile() method of Pandas library can be used to find the nth percentile of a series. To find the 25th and 75th percentiles, we can call the quantile() method with a parameter of 0.25 and 0.75 respectively.
  • We can also pass both values together in the form of a list.

3. Using scipy's 'scoreatpercentile()' method:

  • The scipy.stats.scoreatpercentile() function can be used to find the nth percentile of a series. To find the 25th and 75th percentiles, we can call the scoreatpercentile() function with a parameter of 25 and 75.
  • We can also pass a list of percentile values we want.