daft.Expression.str.lpad#
- Expression.str.lpad(length: int | daft.expressions.expressions.Expression, pad: str | daft.expressions.expressions.Expression) Expression [source]#
Left-pads each string by truncating on the right or padding with the character
Note
If the string is longer than the specified length, it will be truncated on the right. The pad character must be a single character.
Example
>>> import daft >>> df = daft.from_pydict({"x": ["daft", "query", "engine"]}) >>> df = df.select(df["x"].str.lpad(6, "0")) >>> df.show() ╭────────╮ │ x │ │ --- │ │ Utf8 │ ╞════════╡ │ 00daft │ ├╌╌╌╌╌╌╌╌┤ │ 0query │ ├╌╌╌╌╌╌╌╌┤ │ engine │ ╰────────╯ (Showing first 3 of 3 rows)
- Returns:
a String expression which is
self
truncated or left-padded with the pad character- Return type:
Expression