verticapy.vDataFrame.sum#
- vDataFrame.sum(columns: str | list[str] | None = None, **agg_kwargs) TableSample #
Aggregates the vDataFrame 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 vDataColumns names. If empty, all numerical vDataColumns are used.
- **agg_kwargs
Any optional parameter to pass to the Aggregate function.
Returns#
- TableSample
result.
Examples#
For this example, we will use the following dataset:
import verticapy as vp data = vp.vDataFrame( { "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 Note
All the calculations are pushed to the database.
Hint
For more precise control, please refer to the
aggregate
method.