首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >火花并行化集合

火花并行化集合
EN

Stack Overflow用户
提问于 2020-05-20 01:12:29
回答 1查看 253关注 0票数 0

我对火花很陌生,我不能运行并行化集合,这是我的代码:

代码语言:javascript
复制
from pyspark import SparkContext as sc

words = [
    'Apache', 'Spark', 'is', 'an', 'open-source', 'cluster-computing',
    'framework', 'Apache', 'Spark', 'open-source', 'Spark'
]

# Creates a RDD from a list of words

distributed_words = sc.parallelize(words)
distributed_words.count()

和我得到:

代码语言:javascript
复制
TypeError: parallelize() missing 1 required positional argument: 'c'
why?
EN

回答 1

Stack Overflow用户

发布于 2020-05-20 01:23:49

您需要初始化spark Context,我们可以从Spark Session中得到这个值,从Spark-2开始,然后对单词集合进行parallelize

Example:

代码语言:javascript
复制
from pyspark.sql import SparkSession
spark=SparkSession.builder.appName("test").master("local").getOrCreate()
sc=spark.sparkContext
words = [
    'Apache', 'Spark', 'is', 'an', 'open-source', 'cluster-computing',
    'framework', 'Apache', 'Spark', 'open-source', 'Spark'
]
distributed_words = sc.parallelize(words)
distributed_words.count()
#11
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61903455

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档