pyspark.sql.functions.
repeat
Repeats a string column n times, and returns it as a new string column.
New in version 1.5.0.
Changed in version 3.4.0: Supports Spark Connect.
Column
target column to work on.
number of times to repeat value.
string with repeated values.
Examples
>>> df = spark.createDataFrame([('ab',)], ['s',]) >>> df.select(repeat(df.s, 3).alias('s')).collect() [Row(s='ababab')]