Login using Social Account
     Continue with GoogleLogin using your credentials
How to compute average?
Approach 1:
var rdd = sc.parallelize(Array(1.0,2,3, 4, 5 , 6, 7), 3);
var avg = rdd.reduce(_ + _) / rdd.count();
Approach 2:
var rdd = sc.parallelize(Array(1.0,2,3, 4, 5 , 6, 7), 3);
var rdd_count = rdd.map((_, 1))
var (sum, count) = rdd_count.reduce((x, y) => (x._1 + y._1, x._2 + y._2))
var avg = sum / count
Taking you to the next exercise in seconds...
Want to create exercises like this yourself? Click here.
Loading comments...