Indicate that one or multiple columns are sorted
Description
This can speed up future operations, but it can lead to incorrect results if the data is not sorted! Use with care!
Usage
<DataFrame>$set_sorted(column, ..., descending = FALSE)
Arguments
column
|
Column that is sorted. |
…
|
These dots are for future extensions and must be empty. |
descending
|
Whether the columns are sorted in descending order. |
Value
A polars DataFrame
Examples
library("polars")
# We mark the data as sorted by "age" but this is not the case!
# It is up to the user to ensure that the column is actually sorted.
df1 <- pl$DataFrame(
name = c("steve", "elise", "bob"),
age = c(42, 44, 18)
)$set_sorted("age")
df1$flags
#> $name
#> SORTED_ASC SORTED_DESC
#> FALSE FALSE
#>
#> $age
#> SORTED_ASC SORTED_DESC
#> TRUE FALSE