Loading...

vastorbit.VastFrame.avg

VastFrame.avg(columns: Annotated[str | list[str], 'STRING representing one column or a list of columns'] | None = None, **agg_kwargs) TableSample

This operation aggregates the VastFrame using the AVG aggregation, which calculates the average value for the selected column or columns. It provides insights into the central tendency of the data and is a fundamental statistical measure often used in data analysis and reporting.

Parameters:
  • columns (SQLColumns, optional) – List of the VastColumns names. If empty, all VastColumns are used.

  • **agg_kwargs – Any optional parameter to pass to the Aggregate function.

Returns:

result.

Return type:

TableSample

Examples

For this example, we will use the following dataset:

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],
    }
)

Now, let’s calculate the averages for specific columns.

data.avg(
    columns = ["x", "y", "z"],
)
avg
"x"10.375
"y"1.375
"z"5.75
Rows: 1-3 | Columns: 2

Note

All the calculations are pushed to the database.

Hint

For more precise control, please refer to the aggregate method.

See also

VastColumn.avg() : Aggregations for a specific column.
VastFrame.max() : Maximum for particular columns.
VastFrame.min() : Minimum for particular columns.