polars.LazyFrame.slice

LazyFrame.slice(offset: int, length: int) polars.internals.lazy_frame.LDF

Slice the DataFrame.

Parameters
offset

Start index.

length

Length of the slice.

Examples

>>> df = pl.DataFrame(
...     {
...         "a": ["x", "y", "z"],
...         "b": [1, 3, 5],
...         "c": [2, 4, 6],
...     }
... ).lazy()
>>>
>>> df.slice(1, 2).collect()
shape: (2, 3)
┌─────┬─────┬─────┐
│ a   ┆ b   ┆ c   │
│ --- ┆ --- ┆ --- │
│ str ┆ i64 ┆ i64 │
╞═════╪═════╪═════╡
│ y   ┆ 3   ┆ 4   │
├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌┤
│ z   ┆ 5   ┆ 6   │
└─────┴─────┴─────┘