Answers for "wordcount pyspark"

0

wordcount pyspark

text_file = sc.textFile("hdfs://...")
counts = text_file.flatMap(lambda line: line.split(" ")) \
             .map(lambda word: (word, 1)) \
             .reduceByKey(lambda a, b: a + b)
counts.saveAsTextFile("hdfs://...")
Posted by: Guest on June-22-2021

Python Answers by Framework

Browse Popular Code Answers by Language