polars.Series.str.len_bytes#
- Series.str.len_bytes() Series [source]#
Return the length of each string as the number of bytes.
- Returns:
- Series
Series of data type
UInt32
.
See also
Notes
When working with non-ASCII text, the length in bytes is not the same as the length in characters. You may want to use
len_chars()
instead. Note thatlen_bytes()
is much more performant (_O(1)_) thanlen_chars()
(_O(n)_).Examples
>>> s = pl.Series(["Café", "345", "東京", None]) >>> s.str.len_bytes() shape: (4,) Series: '' [u32] [ 5 3 6 null ]