Loading...

vastorbit.VastFrame.sum

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

Aggregates the VastFrame using SUM aggregation, which computes the total sum of values for the specified columns, providing a cumulative view of numerical data.

Parameters:
  • columns (SQLColumns, optional) – List of the VastColumns names. If empty, all numerical 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 sum for specific columns.

data.sum(
    columns = ["x", "y", "z"],
)
sum
"x"83.0
"y"11.0
"z"46.0
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.sum() : Sum for a specific column.
VastFrame.max() : Maximum for particular columns.