pyspark.sql.functions.explode(col: ColumnOrName) → pyspark.sql.column.Column[source]

Returns a new row for each element in the given array or map. Uses the default column name col for elements in the array and key and value for elements in the map unless specified otherwise.

New in version 1.4.0.


>>> from pyspark.sql import Row
>>> eDF = spark.createDataFrame([Row(a=1, intlist=[1,2,3], mapfield={"a": "b"})])
[Row(anInt=1), Row(anInt=2), Row(anInt=3)]
>>>"key", "value")).show()
|  a|    b|