polars.internals.expr.string.ExprStringNameSpace.lengths#

ExprStringNameSpace.lengths() Expr[source]#

Get the length of the Strings as UInt32.

Examples

>>> df = pl.DataFrame({"s": [None, "bears", "110"]})
>>> df.select(["s", pl.col("s").str.lengths().alias("len")])
shape: (3, 2)
┌───────┬──────┐
│ s     ┆ len  │
│ ---   ┆ ---  │
│ str   ┆ u32  │
╞═══════╪══════╡
│ null  ┆ null │
├╌╌╌╌╌╌╌┼╌╌╌╌╌╌┤
│ bears ┆ 5    │
├╌╌╌╌╌╌╌┼╌╌╌╌╌╌┤
│ 110   ┆ 3    │
└───────┴──────┘