Sum

Pydoc Pydoc




Sums all the elements within each aggregation.

Examples

In the following example, we create a pipeline with a PCollection. Then, we get the sum of all the element values in different ways.

Example 1: Sum of the elements in a PCollection

We use Combine.Globally() to get sum of all the element values from the entire PCollection.

Example 2: Sum of the elements for each key

We use Combine.PerKey() to get the sum of all the element values for each unique key in a PCollection of key-values.

Pydoc Pydoc