pyspark.sql.functions.
struct
Creates a new struct column.
cols – list of column names (string) or list of Column expressions
Column
>>> df.select(struct('age', 'name').alias("struct")).collect() [Row(struct=Row(age=2, name='Alice')), Row(struct=Row(age=5, name='Bob'))] >>> df.select(struct([df.age, df.name]).alias("struct")).collect() [Row(struct=Row(age=2, name='Alice')), Row(struct=Row(age=5, name='Bob'))]
New in version 1.4.