polars.Series.str.len_chars#

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

Return the length of each string as the number of characters.

Returns:
Series

Series of data type UInt32.

See also

len_bytes

Notes

When working with ASCII text, use len_bytes() instead to achieve equivalent output with much better performance: len_bytes() runs in _O(1)_, while len_chars() runs in (_O(n)_).

Examples

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