polars.Expr.set_sorted
-
Flags the expression as ‘sorted’.
Enables downstream code to user fast paths for sorted arrays. It is recommended to also set whether
nulls_lastisTrueorFalse, as this enables many internal optimizations.- Parameters:
-
- descending
-
Whether the
Seriesorder is descending. - nulls_last
-
Whether the nulls are at the end.
Warning
This can lead to incorrect results if the data is NOT sorted!! Use with care!
Examples
>>> df = pl.DataFrame({"values": [1, 2, 3]}) >>> df.select(pl.col("values").set_sorted().max()) shape: (1, 1) ┌────────┐ │ values │ │ --- │ │ i64 │ ╞════════╡ │ 3 │ └────────┘
Expr.set_sorted(
*,
descending: bool = False,
nulls_last: 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.set_sorted.html