daft.Expression.str.match

daft.Expression.str.match#

Expression.str.match(pattern: str | daft.expressions.expressions.Expression) Expression[source]#

Checks whether each string matches the given regular expression pattern in a string column

Example

>>> import daft
>>> df = daft.from_pydict({"x": ["foo", "bar", "baz"]})
>>> df.with_column("match", df["x"].str.match("ba.")).collect()
╭──────┬─────────╮
│ x    ┆ match   │
│ ---  ┆ ---     │
│ Utf8 ┆ Boolean │
╞══════╪═════════╡
│ foo  ┆ false   │
├╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
│ bar  ┆ true    │
├╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
│ baz  ┆ true    │
╰──────┴─────────╯

(Showing first 3 of 3 rows)
Parameters:

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

Returns:

a Boolean expression indicating whether each value matches the provided pattern

Return type:

Expression