【发布时间】:2017-12-10 23:30:47
【问题描述】:
我正在尝试将 pyspark 中的 pipelinedRDD 转换为数据帧。这是代码sn-p:
newRDD = rdd.map(lambda row: Row(row.__fields__ + ["tag"])(row + (tagScripts(row), )))
df = newRDD.toDF()
当我运行代码时,我收到了这个错误:
'list' object has no attribute 'encode'
我尝试了多种其他组合,例如使用以下方法将其转换为 Pandas 数据框:
newRDD = rdd.map(lambda row: Row(row.__fields__ + ["tag"])(row + (tagScripts(row), )))
df = newRDD.toPandas()
但是我最终收到了这个错误:
AttributeError: 'PipelinedRDD' object has no attribute 'toPandas'
任何帮助将不胜感激。感谢您的宝贵时间。
【问题讨论】:
标签: python lambda pyspark spark-dataframe rdd