문자열 열을 너비 len 로 좌측 패드로 묶습니다 pad.
해당 Databricks SQL 함수에 대해 알아보려면 lpad 함수를 참조하세요.
문법
from pyspark.databricks.sql import functions as dbf
dbf.lpad(col=<col>, len=<len>, pad=<pad>)
매개 변수
| 매개 변수 | 유형 | Description |
|---|---|---|
col |
pyspark.sql.Column 또는 str |
작업할 대상 열입니다. |
len |
pyspark.sql.Column 또는 int |
마지막 문자열의 길이입니다. |
pad |
pyspark.sql.Column 또는 literal string |
앞에 추가할 chars입니다. |
Returns
pyspark.sql.Column: 왼쪽 패딩된 결과입니다.
예시
from pyspark.databricks.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()