pyspark.sql.functions.array_repeat¶
-
pyspark.sql.functions.
array_repeat
(col: ColumnOrName, count: Union[ColumnOrName, int]) → pyspark.sql.column.Column[source]¶ Collection function: creates an array containing a column repeated count times.
New in version 2.4.0.
Changed in version 3.4.0: Supports Spark Connect.
- Parameters
- Returns
Column
an array of repeated elements.
Examples
>>> df = spark.createDataFrame([('ab',)], ['data']) >>> df.select(array_repeat(df.data, 3).alias('r')).collect() [Row(r=['ab', 'ab', 'ab'])]