ColumnSum
Computes the sum of one or more columns. Furthermore, can compute the sum while being grouped by another column or category, perform a rolling sum or sliding window sum, can compute the sum for only rows that meet a condition, and can add the result to the dataframe as a new column
Options
columns: Specifies columns to calculate sum values
where: Specifies a condition for the calculation
group: Groups the data before performing the operation
rolling: Specifies the rolling window overwhich to perform the calculation
addToDataframe: Indicates whether to add the result to the dataframe
Examples
Example 1 - Compute Sum of a Single Column
Summing the values in a single numeric column gives a quick understanding of total magnitude. In this example, we compute the sum of the AccountBalance column and print the result. This can be used for reporting, summaries, or validation checks.
#> ColumnSum AccountBalance --print
AFLEFT
bankTransactionsDfSum = bankTransactionsDf[AccountBalance].sum()
print(bankTransactionsDfSum) #)2 AFRIGHT