Created
December 12, 2016 16:00
-
-
Save cipri7329/c7f6d1fa540f91fdc251802589898b81 to your computer and use it in GitHub Desktop.
determine what is the most frequent CHARACTER in the file, and how many times was it used
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//In the cell below, determine what is the most frequent CHARACTER in the README, and how many times was it used? | |
//spark and scala | |
var charCounts2 = readme.flatMap(line => line.toList). | |
filter( a => !a.equals("\n") && !a.equals(" ") && !a.equals("") ). | |
filter( _ != ' '). | |
map(character => (character, 1)). | |
reduceByKey((a,b) => a + b). | |
reduce((a, b) => if (a._2 > b._2) a else b) | |
//take(55). | |
//foreach( println) | |
println(charCounts2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment