xarray.core.groupby.DatasetGroupBy.quantile

DatasetGroupBy.quantile(q, dim=None, interpolation='linear', keep_attrs=None)

Compute the qth quantile over each array in the groups and concatenate them together into a new array.

Parameters:
  • q (float in range of [0,1] (or sequence of floats)) – Quantile to compute, which must be between 0 and 1 inclusive.
  • dim (, str or sequence of str, optional) – Dimension(s) over which to apply quantile. Defaults to the grouped dimension.
  • interpolation ({'linear', 'lower', 'higher', 'midpoint', 'nearest'}) –

    This optional parameter specifies the interpolation method to use when the desired quantile lies between two data points i < 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.
Returns:

quantiles – If q is a single quantile, then the result is a scalar. If multiple percentiles are given, first axis of the result corresponds to the quantile. In either case a quantile dimension is added to the return array. The other dimensions are the dimensions that remain after the reduction of the array.

Return type:

Variable

See also

numpy.nanpercentile(), pandas.Series.quantile(), Dataset.quantile(), DataArray.quantile()