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
Notes
When working with ASCII text, use
len_bytes()instead to achieve equivalent output with much better performance:len_bytes()runs in _O(1)_, whilelen_chars()runs in (_O(n)_).Examples
>>> s = pl.Series(["Café", "345", "東京", None]) >>> s.str.len_chars() shape: (4,) Series: '' [u32] [ 4 3 2 null ]