How to explode multiple columns of a dataframe in pyspark

后端 未结 3 807
醉梦人生
醉梦人生 2020-12-25 08:15

I have a dataframe which consists lists in columns similar to the following. The length of the lists in all columns is not same.

Name  Age  Subjects                 


        
3条回答
  •  不思量自难忘°
    2020-12-25 09:19

    Have you tried this

    df.select(explode(split(col("Subjects"))).alias("Subjects")).show()
    

    you can convert the data frame to an RDD.

    For an RDD you can use a flatMap function to separate the Subjects.

提交回复
热议问题