polars.Series.bin.head#

Series.bin.head(n: int = 5) Series[source]#

Take the first n bytes of the binary values.

Parameters:
n

Length of the slice. Negative indexing is supported; see note (2) below.

Returns:
Series

Series of data type Binary.

Notes

  1. A similar method exists for taking the last n bytes: tail().

  2. If n is negative, it is interpreted as “until the nth byte from the end”, e.g., head(-3) returns all but the last three bytes.

Examples

>>> colors = pl.Series([b"\x00\x00\x00", b"\xff\xff\x00", b"\x00\x00\xff"])
>>> colors.bin.head(2)
shape: (3,)
Series: '' [binary]
[
        b"\x00\x00"
        b"\xff\xff"
        b"\x00\x00"
]