我需要在Spark数据帧上进行分布式计算,调用数据帧块上的一些任意(非SQL)逻辑。 我做到了:
def some_func(df_chunk):
pan_df = df_chunk.toPandas()
#whatever logic here
df = sqlContext.read.parquet(...)
result = df.mapPartitions(some_func)
不幸的是,这会导致:
AttributeError: 'itertools.chain' object has no attribute 'toPandas'
我希望在每个映射调用中都有spark DataFrame对象,而不是'itertools.chain'。为什么?如何克服这一点?
试试这个:
相关问题 更多 >
编程相关推荐