pyspark.sql.functions.
concat_ws
Concatenates multiple input string columns together into a single string column, using the given separator.
New in version 1.5.0.
Changed in version 3.4.0: Supports Spark Connect.
words separator.
Column
list of columns to work on.
string of concatenated words.
Examples
>>> df = spark.createDataFrame([('abcd','123')], ['s', 'd']) >>> df.select(concat_ws('-', df.s, df.d).alias('s')).collect() [Row(s='abcd-123')]