xarray.DataArray.quantile¶
-
DataArray.
quantile
(q: Any, dim: Union[Hashable, Sequence[Hashable], None] = None, interpolation: str = 'linear', keep_attrs: Optional[bool] = None) → xarray.core.dataarray.DataArray¶ Compute the qth quantile of the data along the specified dimension.
Returns the qth quantiles(s) of the array elements.
- Parameters
- qfloat in range of [0,1] or array-like of floats
Quantile to compute, which must be between 0 and 1 inclusive.
- dimhashable or sequence of hashable, optional
Dimension(s) over which to apply quantile.
- 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
, wherefraction
is the fractional part of the index surrounded byi
andj
.lower:
i
.higher:
j
.nearest:
i
orj
, whichever is nearest.midpoint:
(i + j) / 2
.
- keep_attrsbool, optional
If True, the dataset’s attributes (attrs) will be copied from the original object to the new one. If False (default), the new object will be returned without attributes.
- Returns
- quantilesDataArray
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 and a quantile dimension is added to the return array. The other dimensions are the
dimensions that remain after the reduction of the array.