June 2017
Beginner to intermediate
296 pages
7h 4m
English
We're now getting close to our answer. We have the information we need in that totalFriendsByCharacter RDD, but we need to find the maximum number of friends for all the people in it. When we want to sort things, we need to flip things around to get what we want. Since we want to get the maximum count of characters, we need to make that count the key. To do that, we just do our usual flippy trick here and have a mapper that swaps the keys with the values. You've seen that a few times before:
flipped = totalFriendsByCharacter.map(lambda (x,y) : (y,x))
What we have now is a key/value RDD where the key is the count and the value is the superhero ID.
Read now
Unlock full access