pyspark.sql.functions.
array_append
Collection function: returns an array of the elements in col1 along with the added element in col2 at the last of the array.
New in version 3.4.0.
Changed in version 3.4.0: Supports Spark Connect.
Column
name of column containing array
a literal value, or a Column expression.
an array of values from first array along with the element.
Examples
>>> from pyspark.sql import Row >>> df = spark.createDataFrame([Row(c1=["b", "a", "c"], c2="c")]) >>> df.select(array_append(df.c1, df.c2)).collect() [Row(array_append(c1, c2)=['b', 'a', 'c', 'c'])] >>> df.select(array_append(df.c1, 'x')).collect() [Row(array_append(c1, x)=['b', 'a', 'c', 'x'])]