I have a dataframe with a map:
sdf = spark.createDataFrame(
[
(1, {'Kira':25,'Lilly':15}),
(2, {'Tom':14}),
],
["id", "label"]
)
+---+-------------------------+
|id |label |
+---+-------------------------+
|1 |{Lilly -> 15, Kira -> 25}|
|2 |{Tom -> 14} |
+---+-------------------------+
And I want to put the keys in one column and the values in another, like this:
+---+-----+---+
|id |name |age|
+---+-----+---+
|1 |Kira |25 |
|1 |Lilly|15 |
|2 |Tom |14 |
+---+-----+---+