Skip to main content
Version: 1.7.1

Expr.str.slice

def slice(
offset: int | td_IntoExprColumn,
length: int | td_IntoExprColumn | None = None,
) -> Expr

Categories: string

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

Parameters

parameter
offset

The offset to start the slice.

parameter
length

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

Examples

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