Answers for ": s = 'Hi hi hi bye bye bye word count’ sc.parallelize(seq).map(lambda word: (word, 1)).reduceByKey(add).collect()"

0

: s = 'Hi hi hi bye bye bye word count’ sc.parallelize(seq).map(lambda word: (word, 1)).reduceByKey(add).collect()

from operator import add

s = 'Hi hi hi bye bye bye word count' 
seq = s.split()   # ['Hi', 'hi', 'hi', 'bye', 'bye', 'bye', 'word', 'count']
sc.parallelize(seq)\
  .map(lambda word: (word, 1))\
  .reduceByKey(add)\
  .collect()
Posted by: Guest on September-03-2020

Browse Popular Code Answers by Language