HTTP/2 301
server: GitHub.com
content-type: text/html
location: https://docs.pola.rs/py-polars/html/reference/expressions/api/polars.head.html
x-github-request-id: 4BA4:B90F7:16965B:1A702F:6889F491
accept-ranges: bytes
age: 0
date: Wed, 30 Jul 2025 10:31:45 GMT
via: 1.1 varnish
x-served-by: cache-bom-vanm7210054-BOM
x-cache: MISS
x-cache-hits: 0
x-timer: S1753871506.643068,VS0,VE213
vary: Accept-Encoding
x-fastly-request-id: d9261cc53f903c4f09c3282810b8bd968657a709
content-length: 162
HTTP/2 200
server: GitHub.com
content-type: text/html; charset=utf-8
last-modified: Tue, 29 Jul 2025 17:45:24 GMT
access-control-allow-origin: *
strict-transport-security: max-age=31556952
etag: W/"688908b4-35a85"
expires: Wed, 30 Jul 2025 10:41:46 GMT
cache-control: max-age=600
content-encoding: gzip
x-proxy-cache: MISS
x-github-request-id: E4B0:80743:164C08:1A267F:6889F48A
accept-ranges: bytes
age: 0
date: Wed, 30 Jul 2025 10:31:46 GMT
via: 1.1 varnish
x-served-by: cache-bom-vanm7210058-BOM
x-cache: MISS
x-cache-hits: 0
x-timer: S1753871506.987810,VS0,VE222
vary: Accept-Encoding
x-fastly-request-id: b550dfc00f775c2f4525fc0b808ca5f509240fce
content-length: 18591
polars.head — Polars documentation
Skip to main content
polars.head
-
polars.head(column: str, n: int = 10) → Expr[source]
Get the first n
rows.
This function is syntactic sugar for pl.col(column).head(n)
.
- Parameters:
- column
Column name.
- 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 │
└─────┘