tabsdata.tableframe.expr.string.ExprStringNameSpace.slice#

ExprStringNameSpace.slice(offset: int | Expr | Series | str, length: int | Expr | Series | str | None = None) Expr[source]#

Extract the substring at the given offset for the given length.

Parameters:
  • offset – The offset to start the slice.

  • length – The length of the slice. If None, slice until the end of the string.

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
>>> tf.select(td.col("a"), td.col("a").str.slice(1,1).alias("slice"))
>>>
┌──────┬───────┐
│ a    ┆ slice │
│ ---  ┆ ---   │
│ str  ┆ str   │
╞══════╪═══════╡
│ abc  ┆ b     │
│ a    ┆       │
│ null ┆ null  │
└──────┴───────┘