📜  : s = 'Hi hi hi bye bye bye word count' sc.parallelize(seq).map(lambda word: (word, 1)).reduceByKey(add).collect() - 任何代码示例

📅  最后修改于: 2022-03-11 14:57:34.634000             🧑  作者: Mango

代码示例1
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()