HTTP/2 301
server: GitHub.com
content-type: text/html
x-origin-cache: HIT
location: https://docs.pola.rs/py-polars/html/reference/expressions/api/polars.head.html
x-github-request-id: B1FE:3CC54B:5ACC4:6F025:68887FD2
accept-ranges: bytes
age: 0
date: Tue, 29 Jul 2025 08:01:23 GMT
via: 1.1 varnish
x-served-by: cache-bom-vanm7210097-BOM
x-cache: MISS
x-cache-hits: 0
x-timer: S1753776083.958934,VS0,VE203
vary: Accept-Encoding
x-fastly-request-id: 82b7fa8b7552a4ec63f26228cde9fa17f0a7cae2
content-length: 162
HTTP/2 200
server: GitHub.com
content-type: text/html; charset=utf-8
x-origin-cache: HIT
last-modified: Mon, 28 Jul 2025 23:59:40 GMT
access-control-allow-origin: *
strict-transport-security: max-age=31556952
etag: W/"68880eec-35a85"
expires: Tue, 29 Jul 2025 08:11:23 GMT
cache-control: max-age=600
content-encoding: gzip
x-proxy-cache: MISS
x-github-request-id: F482:29FBE4:5E743:72A94:68887FD1
accept-ranges: bytes
age: 0
date: Tue, 29 Jul 2025 08:01:23 GMT
via: 1.1 varnish
x-served-by: cache-bom-vanm7210031-BOM
x-cache: MISS
x-cache-hits: 0
x-timer: S1753776083.272804,VS0,VE230
vary: Accept-Encoding
x-fastly-request-id: a0da8e76dcb3cd8a197127afd297577d188ccab4
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 │
└─────┘