dask.bag.Bag.reduction

Bag.reduction(perpartition, aggregate, split_every=None, out_type=<class 'dask.bag.core.Item'>, name=None)[source]

Reduce collection with reduction operators.

Parameters
perpartition: function

reduction to apply to each partition

aggregate: function

reduction to apply to the results of all partitions

split_every: int (optional)

Group partitions into groups of this size while performing reduction Defaults to 8

out_type: {Bag, Item}

The out type of the result, Item if a single element, Bag if a list of elements. Defaults to Item.

Examples

>>> import dask.bag as db
>>> b = db.from_sequence(range(10))
>>> b.reduction(sum, sum).compute()
45