polars.last#

polars.last(column: str) Expr[source]#
polars.last(column: Series) Any
polars.last(column: None = None) Expr

Get the last value.

Depending on the input type this function does different things:

  • None -> expression to take last column of a context.

  • str -> syntactic sugar for pl.col(..).last()

  • Series -> Take last value in Series

Examples

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