pyspark.sql.functions.concat_ws#
- pyspark.sql.functions.concat_ws(sep, *cols)[source]#
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.
- Parameters
- sepstr
words separator.
- cols
Column
or str list of columns to work on.
- Returns
Column
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')]