tabsdata.tableframe.expr.string.ExprStringNameSpace.extract#

ExprStringNameSpace.extract(pattern: Expr | Series | str, group_index: int = 1) Expr[source]#

Extract a pattern from the string.

Parameters:
  • pattern – The pattern to extract.

  • group_index – The group index to extract.

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
>>> tf.select(td.col("a"), td.col("a").str.extract("(b.b)", 1).alias("extract"))
>>>
┌───────────┬─────────┐
│ a         ┆ extract │
│ ---       ┆ ---     │
│ str       ┆ str     │
╞═══════════╪═════════╡
│ a bAb c d ┆ bAb     │
│ bCbb c d  ┆ bCb     │
│ bb        ┆ null    │
│ null      ┆ null    │
└───────────┴─────────┘