polars.head#

polars.head(column: str, n: int = 10) Expr[source]#
polars.head(column: Series, n: int = 10) Series

Get the first n rows.

Parameters:
column

Column name or Series.

n

Number of rows to return.

Examples

>>> df = pl.DataFrame({"a": [1, 8, 3], "b": [4, 5, 2], "c": ["foo", "bar", "foo"]})
>>> df.select(pl.head("a"))
shape: (3, 1)
┌─────┐
│ a   │
│ --- │
│ i64 │
╞═════╡
│ 1   │
│ 8   │
│ 3   │
└─────┘
>>> df.select(pl.head("a", 2))
shape: (2, 1)
┌─────┐
│ a   │
│ --- │
│ i64 │
╞═════╡
│ 1   │
│ 8   │
└─────┘