Expr.str.head
methodView source ↗
def head(n: int | td_IntoExprColumn) -> Expr
Categories: string
Extract the start of the string up to the given length.
Parameters
parameter
nThe length of the head.
Examples
>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
>>> tf.select(td.col("a"), td.col("a").str.head(2).alias("head"))
>>>
┌──────┬──────┐
│ a ┆ head │
│ --- ┆ --- │
│ str ┆ str │
╞══════╪══════╡
│ abc ┆ ab │
│ a ┆ a │
│ null ┆ null │
└──────┴──────┘