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.
Left-pad the string column to width len with pad.
For the corresponding Databricks SQL function, see lpad function.
Syntax
from pyspark.sql import functions as dbf
dbf.lpad(col=<col>, len=<len>, pad=<pad>)
Parameters
| Parameter | Type | Description |
|---|---|---|
col |
pyspark.sql.Column or str |
target column to work on. |
len |
pyspark.sql.Column or int |
length of the final string. |
pad |
pyspark.sql.Column or literal string |
chars to prepend. |
Returns
pyspark.sql.Column: left padded result.
Examples
from pyspark.sql import functions as dbf
df = spark.createDataFrame([('abcd',), ('xyz',), ('12',)], ['s',])
df.select("*", dbf.lpad(df.s, 6, '#')).show()
df = spark.createDataFrame([('abcd',), ('xyz',), ('12',)], ['s',])
df.select("*", dbf.lpad(df.s, 6, dbf.lit(b"\x75\x76"))).show()