daft.Expression.binary.slice

daft.Expression.binary.slice#

Expression.binary.slice(start: daft.expressions.expressions.Expression | int, length: Optional[Union[Expression, int]] = None) Expression[source]#

Returns a slice of each binary string.

Example

>>> import daft
>>> df = daft.from_pydict({"x": [b"Hello World", b"\xff\xfe\x00", b"empty"]})
>>> df = df.select(df["x"].binary.slice(1, 3))
>>> df.show()
╭─────────────╮
│ x           │
│ ---         │
│ Binary      │
╞═════════════╡
│ b"ell"      │
├╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ b"\xfe\x00" │
├╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ b"mpt"      │
╰─────────────╯

(Showing first 3 of 3 rows)
Parameters:
  • start – The starting position (0-based) of the slice.

  • length – The length of the slice. If None, returns all characters from start to the end.

Returns:

A new expression representing the slice.