polars.first#
- polars.first(column: str) Expr [source]#
- polars.first(column: Series) Any
- polars.first(column: None = None) Expr
Get the first value.
Depending on the input type this function does different things:
input:
None -> expression to take first column of a context.
str -> syntactic sugar for pl.col(..).first()
Series -> Take first value in Series
Examples
>>> df = pl.DataFrame({"a": [1, 8, 3], "b": [4, 5, 2], "c": ["foo", "bar", "foo"]}) >>> df.select(pl.first()) shape: (3, 1) ┌─────┐ │ a │ │ --- │ │ i64 │ ╞═════╡ │ 1 │ │ 8 │ │ 3 │ └─────┘ >>> df.select(pl.first("a")) shape: (1, 1) ┌─────┐ │ a │ │ --- │ │ i64 │ ╞═════╡ │ 1 │ └─────┘