daft.Expression.str.find#
- Expression.str.find(substr: str | daft.expressions.expressions.Expression) Expression [source]#
Returns the index of the first occurrence of the substring in each string.
Note
The returned index is 0-based. If the substring is not found, -1 is returned.
Example
>>> import daft >>> df = daft.from_pydict({"x": ["daft", "query daft", "df_daft"]}) >>> df = df.select(df["x"].str.find("daft")) >>> df.show() ╭───────╮ │ x │ │ --- │ │ Int64 │ ╞═══════╡ │ 0 │ ├╌╌╌╌╌╌╌┤ │ 6 │ ├╌╌╌╌╌╌╌┤ │ 3 │ ╰───────╯ (Showing first 3 of 3 rows)
- Returns:
an Int64 expression with the index of the first occurrence of the substring in each string
- Return type:
Expression