How to convert a list of array to Spark dataframe

半腔热情 提交于 2019-12-24 07:46:25

问题


Suppose I have a list:

x = [[1,10],[2,14],[3,17]]

I want to convert x to a Spark dataframe with two columns id (1,2,3) and value (10,14,17).

How could I do that?

Thanks


回答1:


x = [[1,10],[2,14],[3,17]]
df = sc.parallelize(x).toDF(['ID','VALUE'])
df.show()


来源:https://stackoverflow.com/questions/45858900/how-to-convert-a-list-of-array-to-spark-dataframe

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!