How to convert a list of array to Spark dataframe

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

Related videos on Youtube

mommomonthewind
Author by

mommomonthewind

Updated on June 04, 2022

Comments

  • mommomonthewind
    mommomonthewind over 1 year

    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