Skip to main content
Version: 1.9.1

Expr.str.head

def head(n: int | td_IntoExprColumn) -> Expr

Categories: string

Extract the start of the string up to the given length.

Parameters

parameter
n

The 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 │
------
strstr
╞══════╪══════╡
│ abc ┆ ab │
│ a ┆ a │
│ null ┆ null │
└──────┴──────┘