python pyspark-wordcount-mapPartitions.py

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python pyspark-wordcount-mapPartitions.py相关的知识,希望对你有一定的参考价值。

path = "/Users/itversity/Research/data/wordcount.txt" or path = "/public/randomtextwriter/part-m-00000"

def getTuples(lines):
    tuples = [ ]
    for line in lines:
        for i in line.split(" "):
            tuples.append((i, 1))
    return tuples

for i in sc.textFile(path). \
    mapPartitions(lambda lines: getTuples(lines)). \
    reduceByKey(lambda t, e: t + e). \
    take(100):
    print(i)

以上是关于python pyspark-wordcount-mapPartitions.py的主要内容,如果未能解决你的问题,请参考以下文章

Python代写,Python作业代写,代写Python,代做Python

Python开发

Python,python,python

Python 介绍

Python学习之认识python

python初识