Answers for "Aggregate the elements of each partition, and then the results for all the partitions"

0

Aggregate the elements of each partition, and then the results for all the partitions

#Aggregate the elements of each partition, and then the results for all the partitions

seqOp = (lambda x, y: (x[0] + y, x[1] + 1))
combOp = (lambda x, y: (x[0] + y[0], x[1], y[1]))
sc.parallelize([1, 2, 3, 4]).aggregate((0, 0), seqOp, combOp)
# (10, 4)
sc.parallelize([]).aggregate((0, 0), seqOp, combOp)
# (0, 0)
Posted by: Guest on April-08-2020

Code answers related to "Aggregate the elements of each partition, and then the results for all the partitions"

Python Answers by Framework

Browse Popular Code Answers by Language