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
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.
flatMap