Lưu ý
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử đăng nhập hoặc thay đổi thư mục.
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử thay đổi thư mục.
Repeats a string column n times, and returns it as a new string column.
For the corresponding Databricks SQL function, see repeat function.
Syntax
from pyspark.databricks.sql import functions as dbf
dbf.repeat(col=<col>, n=<n>)
Parameters
| Parameter | Type | Description |
|---|---|---|
col |
pyspark.sql.Column or str |
target column to work on. |
n |
pyspark.sql.Column or str or int |
number of times to repeat value. |
Returns
pyspark.sql.Column: string with repeated values.
Examples
from pyspark.databricks.sql import functions as dbf
df = spark.createDataFrame([('ab',)], ['s',])
df.select("*", dbf.repeat("s", 3)).show()
df.select("*", dbf.repeat(df.s, dbf.lit(4))).show()
df = spark.createDataFrame([('ab', 5,), ('abc', 6,)], ['s', 't'])
df.select("*", dbf.repeat("s", "t")).show()