slice_head¶
- pydiverse.transform.slice_head(n: int, *, offset: int = 0) Pipeable[source]¶
Selects a subset of rows based on their index.
- Parameters:
n – The number of rows to select.
offset – The index of the first row (0-based) that is included in the selection.
Examples
>>> t = pdt.Table( ... { ... "a": [65, 5, 312, -55, 0], ... "b": ["l", "r", "srq", "---", " "], ... } ... ) >>> t >> slice_head(3, offset=1) >> show() shape: (3, 2) ┌─────┬─────┐ │ a ┆ b │ │ --- ┆ --- │ │ i64 ┆ str │ ╞═════╪═════╡ │ 5 ┆ r │ │ 312 ┆ srq │ │ -55 ┆ --- │ └─────┴─────┘