📅  最后修改于: 2022-03-11 14:57:34.634000             🧑  作者: Mango
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()