Calculate the n-th discrete difference of every sublist.
Optional
n: numbernumber of slots to shift
Optional
nullBehavior: "ignore" | "drop"'ignore' | 'drop'
s = pl.Series("a", [[1, 2, 3, 4], [10, 2, 1]])
s.lst.diff()
shape: (2,)
Series: 'a' [list]
[
[null, 1, ... 1]
[null, -8, -1]
]
Expression to run. Note that you can select an element with pl.first()
, or pl.col()
Optional
parallel: booleanRun all expression parallel. Don't activate this blindly. Parallelism is worth it if there is enough work to do per thread. This likely should not be use in the groupby context, because we already parallel execution per group
>df = pl.DataFrame({"a": [1, 8, 3], "b": [4, 5, 2]})
>df.withColumn(
... pl.concatList(["a", "b"]).lst.eval(pl.first().rank()).alias("rank")
... )
shape: (3, 3)
┌─────┬─────┬────────────┐
│ a ┆ b ┆ rank │
│ --- ┆ --- ┆ --- │
│ i64 ┆ i64 ┆ list [f32] │
╞═════╪═════╪════════════╡
│ 1 ┆ 4 ┆ [1.0, 2.0] │
├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┤
│ 8 ┆ 5 ┆ [2.0, 1.0] │
├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┤
│ 3 ┆ 2 ┆ [2.0, 1.0] │
└─────┴─────┴────────────┘
Sort the sublists.
Optional
descending: booleanSort in reverse order.
since 0.16.0 Use descending instead
List functions for Series