pyspark.sql.functions.lpad¶
-
pyspark.sql.functions.
lpad
(col: ColumnOrName, len: int, pad: str) → pyspark.sql.column.Column[source]¶ Left-pad the string column to width len with pad.
New in version 1.5.0.
Changed in version 3.4.0: Supports Spark Connect.
- Parameters
- col
Column
or str target column to work on.
- lenint
length of the final string.
- padstr
chars to prepend.
- col
- Returns
Column
left padded result.
Examples
>>> df = spark.createDataFrame([('abcd',)], ['s',]) >>> df.select(lpad(df.s, 6, '#').alias('s')).collect() [Row(s='##abcd')]