polars.Expr.first
-
Get the first value.
- Parameters:
-
- ignore_nulls
-
Ignore null values (default
False). If set toTrue, the first non-null value is returned, otherwiseNoneis returned if no non-null value exists.
Examples
>>> df = pl.DataFrame({"a": [None, 1, 2]}) >>> df.select(pl.col("a").first()) shape: (1, 1) ┌──────┐ │ a │ │ --- │ │ i64 │ ╞══════╡ │ null │ └──────┘ >>> df.select(pl.col("a").first(ignore_nulls=True)) shape: (1, 1) ┌─────┐ │ a │ │ --- │ │ i64 │ ╞═════╡ │ 1 │ └─────┘
Expr.first(
*,
ignore_nulls: bool = False,
) → Expr
© 2020 Ritchie Vink
© 2022 Polars contributors
Licensed under the MIT License.
https://docs.pola.rs/api/python/stable/reference/expressions/api/polars.Expr.first.html