Word count program

instead of just using the count() ; I not sure why this logic will not give the results jsonRDD.flatMap(lambda x: tuple(x.split(":"))).map(lambda x: (x,1)).reduce(lambda x,y: x[1]+y[1])

To get the word count you need to use reduceByKey not reduce.

but it will give only word count but if i have count the no of words what needs to be done with reduce function

You should use count. That is it. Why do you want to complicate the things?

lol , just want to understand what i missing hereā€¦ Will use count for the Exam.

Here is the complicated way of getting the count :slight_smile: . Probably you should use more complex examples like min, max, sum etc

wordcountRDD.flatMap(lambda x: x.split(" ")).map(lambda x: 1).reduce(lambda x,y: x + y)

Thanks :slight_smile: