Expr.str.slice
methodView source ↗
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
offsetThe offset to start the slice.
parameter
lengthThe 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 │
│ --- ┆ --- │
│ str ┆ str │
╞══════╪═══════╡
│ abc ┆ b │
│ a ┆ │
│ null ┆ null │
└──────┴───────┘