June 2017
Beginner to intermediate
296 pages
7h 4m
English
Now we have our final results, all we have to do is call collect to get them and print them out:
results = averagesByAge.collect()
for result in results:
print(result)
One thing I want to mention is that remember nothing actually happens in Spark until the first action is called. If you go back to when we called reduceByKey, that's actually the first action in our code so nothing actually occurred in our script until reduceByKey was called, which is kind of interesting:
reduceByKey(lambda x, y: (x[0] + y[0], x[1] + y[1]))
The other action that we have in our script is this collect call:
results = averagesByAge.collect()
At both stages, Spark will go out and actually construct that directed acyclic graph ...
Read now
Unlock full access