pyspark.sql.functions.map_from_entries¶
-
pyspark.sql.functions.
map_from_entries
(col)[source]¶ Collection function: Returns a map created from the given array of entries.
- Parameters
col – name of column or expression
>>> from pyspark.sql.functions import map_from_entries >>> df = spark.sql("SELECT array(struct(1, 'a'), struct(2, 'b')) as data") >>> df.select(map_from_entries("data").alias("map")).show() +----------------+ | map| +----------------+ |[1 -> a, 2 -> b]| +----------------+
New in version 2.4.