w3resource

Pandas Series: quantile() function

Value at the given quantile

The quantile() function is used to get value at the given quantile.

Syntax:

Series.quantile(self, q=0.5, interpolation='linear')
Pandas Series quantile image

Parameters:

Name Description Type/Default Value Required / Optional
q 0 <= q <= 1, the quantile(s) to compute. float or array-like
Default Value: 0.5 (50% quantile)
Required
interpolation This optional parameter specifies the interpolation method to use, when the desired quantile lies between two data points i and j:
  • linear: i + (j - i) * fraction, where fraction is the fractional part of the index surrounded by i and j.
  • lower: i.
  • higher: j.
  • nearest: i or j whichever is nearest.
  • midpoint: (i + j) / 2.
{‘linear’, ‘lower’, ‘higher’, ‘midpoint’, ‘nearest’} Required

Returns: float or Series
If q is an array, a Series will be returned where the index is q and the values are the quantiles, otherwise a float will be returned.

Example:


Download the above Notebook from here.



Inviting useful, relevant, well-written and unique guest posts