xarray.Variable.quantile#
- Variable.quantile(q, dim=None, method='linear', keep_attrs=None, skipna=None, interpolation=None)[source]#
Compute the qth quantile of the data along the specified dimension.
Returns the qth quantiles(s) of the array elements.
- Parameters:
q (
float
or sequence offloat
) – Quantile to compute, which must be between 0 and 1 inclusive.dim (
str
or sequence ofstr
, optional) – Dimension(s) over which to apply quantile.method (
str
, default:"linear"
) – This optional parameter specifies the interpolation method to use when the desired quantile lies between two data points. The options sorted by their R type as summarized in the H&F paper [1] are:“inverted_cdf” (*)
“averaged_inverted_cdf” (*)
“closest_observation” (*)
“interpolated_inverted_cdf” (*)
“hazen” (*)
“weibull” (*)
“linear” (default)
“median_unbiased” (*)
“normal_unbiased” (*)
The first three methods are discontiuous. The following discontinuous variations of the default “linear” (7.) option are also available:
“lower”
“higher”
“midpoint”
“nearest”
See
numpy.quantile()
or [1] for details. The “method” argument was previously called “interpolation”, renamed in accordance with numpy version 1.22.0.(*) These methods require numpy version 1.22 or newer.
keep_attrs (
bool
, optional) – If True, the variable’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.skipna (
bool
, optional) – If True, skip missing values (as marked by NaN). By default, only skips missing values for float dtypes; other dtypes either do not have a sentinel missing value (int) or skipna=True has not been implemented (object, datetime64 or timedelta64).
- Returns:
quantiles (
Variable
) – 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.
References