vastorbit.VastColumn.quantile¶
- VastColumn.quantile(q: Annotated[int | float | Decimal, 'Python Numbers'], approx: bool = True) Annotated[bool | float | str | timedelta | datetime, 'Python Scalar']¶
Aggregates the VastColumn using a specified
quantile. Thequantilefunction is an indispensable tool for comprehending data distribution. By providing a quantile value as input, this aggregation method helps us identify the data point below which a certain percentage of the data falls. This can be pivotal for tasks like analyzing data distributions, assessing skewness, and determining essential percentiles such as medians or quartiles.Warning
It’s important to note that the
quantileaggregation operates in two distinct modes, allowing flexibility in computation. Depending on theapproxparameter, it can use eitherAPPROXIMATE_QUANTILEorQUANTILEmethods to derive the final aggregation. TheAPPROXIMATE_QUANTILEmethod provides faster results by estimating the quantile values with an approximation technique, whileQUANTILEcalculates precise quantiles through rigorous computation. This choice empowers users to strike a balance between computational efficiency and the level of precision required for their specific data analysis tasks.- Parameters:
q (PythonNumber) – A float between 0 and 1 that represents the quantile. For example: 0.25 represents Q1.
approx (bool, optional) – If set to True, the approximate quantile is returned. By setting this parameter to False, the function’s performance can drastically decrease.
- Returns:
quantile (or approximate quantile).
- Return type:
PythonScalar
Examples
For this example, let’s generate a dataset and calculate the approximate median of a column:
import vastorbit as vo data = vo.VastFrame( { "x": [1, 2, 4, 9, 10, 15, 20, 22], "y": [1, 2, 1, 2, 1, 1, 2, 1], "z": [10, 12, 2, 1, 9, 8, 1, 3], } ) data["x"].quantile(q = 0.5, approx = True)
Let’s compute the approximate last decile of a column.
data["x"].quantile(q = 0.9, approx = True)
Note
All the calculations are pushed to the database.
Hint
For more precise control, please refer to the
aggregatemethod.See also
VastColumn.aggregate(): Aggregations for a specific column.VastFrame.aggregate(): Aggregates for particular columns.