daft.Expression.str.contains

daft.Expression.str.contains#

Expression.str.contains(substr: str | daft.expressions.expressions.Expression) Expression[source]#

Checks whether each string contains the given pattern in a string column

Example

>>> import daft
>>> df = daft.from_pydict({"x": ["foo", "bar", "baz"]})
>>> df = df.select(df["x"].str.contains("o"))
>>> df.show()
╭─────────╮
│ x       │
│ ---     │
│ Boolean │
╞═════════╡
│ true    │
├╌╌╌╌╌╌╌╌╌┤
│ false   │
├╌╌╌╌╌╌╌╌╌┤
│ false   │
╰─────────╯

(Showing first 3 of 3 rows)
Parameters:

pattern – pattern to search for as a literal string, or as a column to pick values from

Returns:

a Boolean expression indicating whether each value contains the provided pattern

Return type:

Expression