pyspark.sql.functions.concat¶
-
pyspark.sql.functions.
concat
(*cols: ColumnOrName) → pyspark.sql.column.Column¶ Concatenates multiple input columns together into a single column. The function works with strings, binary and compatible array columns.
Examples
>>> df = spark.createDataFrame([('abcd','123')], ['s', 'd']) >>> df.select(concat(df.s, df.d).alias('s')).collect() [Row(s='abcd123')]
>>> df = spark.createDataFrame([([1, 2], [3, 4], [5]), ([1, 2], None, [3])], ['a', 'b', 'c']) >>> df.select(concat(df.a, df.b, df.c).alias("arr")).collect() [Row(arr=[1, 2, 3, 4, 5]), Row(arr=None)]