赞
踩
第一关 WordCount - 词频统计
文本文件内容如下(单词与单词之间以空格进行分割):
hello java
hello python java
hello python python
hello flink
scala scala scala scala scala
预期输出: (scala,5)
(hello,4)
(python,3)
(java,2)
(flink,1)
- # -*- coding: UTF-8 -*-
- from pyspark import SparkContext
-
- if __name__ == "__main__":
-
- """
- 需求:对本地文件系统URI为:/root/wordcount.txt 的内容进行词频统计
- """
- # ********** Begin **********#
-
- sc = SparkContext("local","pySpark")
- rdd = sc.textFile("/root/wordcount.txt
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。