daft.Expression.str.left

daft.Expression.str.left#

Expression.str.left(nchars: int | daft.expressions.expressions.Expression) Expression[source]#

Gets the n (from nchars) left-most characters of each string

Example

>>> import daft
>>> df = daft.from_pydict({"x": ["daft", "query", "engine"]})
>>> df = df.select(df["x"].str.left(4))
>>> df.show()
╭──────╮
│ x    │
│ ---  │
│ Utf8 │
╞══════╡
│ daft │
├╌╌╌╌╌╌┤
│ quer │
├╌╌╌╌╌╌┤
│ engi │
╰──────╯

(Showing first 3 of 3 rows)
Returns:

a String expression which is the n left-most characters of self

Return type:

Expression