polars.Series.str.lengths#

Series.str.lengths() Series[source]#

Get length of the string values in the Series (as number of bytes).

Returns:
Series[u32]

Notes

The returned lengths are equal to the number of bytes in the UTF8 string. If you need the length in terms of the number of characters, use n_chars instead.

Examples

>>> s = pl.Series(["Café", None, "345", "東京"])
>>> s.str.lengths()
shape: (4,)
Series: '' [u32]
[
    5
    null
    3
    6
]