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

ExprStringNameSpace.slice(offset: int | td_typing.IntoExprColumn, length: int | td_typing.IntoExprColumn | None = None) td_expr.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  │
└──────┴───────┘