【发布时间】:2016-04-13 21:26:35
【问题描述】:
我是 spark 的新手,我的任务是从一组推文中为小字母表中的每个字符获取前一百个单词。例如
a: (word1, count1), (word2, count2).. (word100, count100)
b: (word1, count1), (word2, count2).. (word100, count100)
.
.
z: (word1, count1), (word2, count2).. (word100, count100)
这是我的代码:
words_mapped = (en_text.flatMap(lambda x: x.split())
.filter(lambda x: x[0] in valid_chars )
.map(lambda x: (x[0], x)))
这给出了一个包含字符和单词的元组,现在我必须对这些字符进行分组,并在值中找到每个单词的计数,并显示前 100 个单词及其计数。
我怎样才能把它翻译成 pyspark。
【问题讨论】:
-
你的“性格”是什么意思
-
@Natecat 我已经更新了问题,小字母的字符,另见示例
标签: python apache-spark lambda pyspark rdd