polars.Series.cat.len_bytes#
- Series.cat.len_bytes() Series [source]#
Return the byte-length of the string representation of each value.
- 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], dtype=pl.Categorical) >>> s.cat.len_bytes() shape: (4,) Series: '' [u32] [ 5 3 6 null ]