modin.pandas.DataFrame.quantile¶
- DataFrame.quantile(q=0.5, axis=0, numeric_only=False, interpolation='linear', method='single') Union[DataFrame, Series] [source] (https://github.com/snowflakedb/snowpark-python/blob/v1.26.0/snowpark-python/.tox/docs/lib/python3.9/site-packages/modin/pandas/dataframe.py#L1661-L1675)¶
Return values at the given quantile over requested axis.
- Parameters:
q (float or array-like of float, default 0.5) – Value between 0 <= q <= 1, the quantile(s) to compute.
axis ({0 or 'index', 1 or 'columns'}, default 0) – Axis across which to compute quantiles.
numeric_only (bool, default False) – Include only data where is_numeric_dtype is true. When True, bool columns are included, but attempting to compute quantiles across bool values is an ill-defined error in both pandas and Snowpark pandas.
interpolation ({"linear", "lower", "higher", "midpoint", "nearest"}, default "linear") –
Specifies the interpolation method to use if a 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.
Snowpark pandas currently only supports “linear” and “nearest”.
method ({"single", "table"}, default "single") – Whether to compute quantiles per-column (“single”) or over all columns (“table”). When “table”, the only allowed interpolation methods are “nearest”, “lower”, and “higher”.
- Returns:
If
q
is an array, a DataFrame will be returned where the index isq
, the columns are the columns ofself
, and the values are the quantiles. Ifq
is a float, a Series will be returned where the index is the columns ofself
and the values are the quantiles.- Return type:
Examples
>>> df = pd.DataFrame(np.array([[1, 1], [2, 10], [3, 100], [4, 100]]), columns=['a', 'b'])
With a scalar q:
>>> df.quantile(.1) a 1.3 b 3.7 Name: 0.1, dtype: float64
With a list q:
>>> df.quantile([.1, .5]) a b 0.1 1.3 3.7 0.5 2.5 55.0
Values considered NaN do not affect the result:
>>> df = pd.DataFrame({"a": [None, 0, 25, 50, 75, 100, np.nan]}) >>> df.quantile([0, 0.25, 0.5, 0.75, 1]) a 0.00 0.0 0.25 25.0 0.50 50.0 0.75 75.0 1.00 100.0
Notes
Currently only supports calls with axis=0.
Also, unsupported if q is a Snowpandas DataFrame or Series.