从列表的RDD创建Spark DataFrame [英] Creating a Spark DataFrame from an RDD of lists
本文介绍了从列表的RDD创建Spark DataFrame的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个rdd(我们可以称其为myrdd),其中rdd中的每条记录都采用以下格式:
I have an rdd (we can call it myrdd) where each record in the rdd is of the form:
[('column 1',value), ('column 2',value), ('column 3',value), ... , ('column 100',value)]
我想将其转换为pyspark中的DataFrame-最简单的方法是什么?
I would like to convert this into a DataFrame in pyspark - what is the easiest way to do this?
推荐答案
如何使用toDF
方法?您只需要添加字段名称.
How about use the toDF
method? You only need add the field names.
df = rdd.toDF(['column', 'value'])
这篇关于从列表的RDD创建Spark DataFrame的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文