w3resource

Pandas DataFrame: quantile() function

DataFrame - quantile() function

The quantile() function is used to get values at the given quantile over requested axis.

Syntax:

DataFrame.quantile(self, q=0.5, axis=0, numeric_only=True, interpolation='linear')

Parameters:

Name Description Type/Default Value Required / Optional
Value between 0 <= q <= 1, the quantile(s) to compute. float or array-like
Default Value: 0.5 (50% quantile)
Required
axis Equals 0 or ‘index’ for row-wise, 1 or ‘columns’ for column-wise. {0, 1, ‘index’, ‘columns’}
Default Value: 0
Required
numeric_only    If False, the quantile of datetime and timedelta data will be computed as well. bool
Default Value: True
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: Series or DataFrame
If q is an array, a DataFrame will be returned where the index is q, the columns are the columns of self, and the values are the quantiles.
If q is a float, a Series will be returned where the index is the columns of self and the values are the quantiles.

Example:


Download the Pandas DataFrame Notebooks from here.

Previous: DataFrame - product() function
Next: DataFrame - rank() function



Follow us on Facebook and Twitter for latest update.