I would highly prefer the first behavior, as it is what Python does for negative index out-of-bounds:
>>> [1,2,3,4,5][-6:]
[1, 2, 3, 4, 5]
Log output
No response
Issue description
Often there is a need to support capping a list to some maximum length. I know there are other ways to achieve what I want, but it seems like the above behavior should be consistent as the docs do not specify any functional difference between slicing on a DataFrame/Series/Expr.
Expected behavior
I would expect all three examples to return [1,2,3,4,5] (in the applicable datastructure), as slicing beyond the beginning of the list in Python tends to clamp to the beginning rather than loop back around to the end.
And the expressions pl.DataFrame({"a": [1,2,3,4,5]}).slice(-10) and pl.Series([1,2,3,4,5]).slice(-10) return an empty df / series.
(with slice(-9) they return only the first value: 1)
Checks
Reproducible example
I would highly prefer the first behavior, as it is what Python does for negative index out-of-bounds:
Log output
No response
Issue description
Often there is a need to support capping a list to some maximum length. I know there are other ways to achieve what I want, but it seems like the above behavior should be consistent as the docs do not specify any functional difference between slicing on a DataFrame/Series/Expr.
Expected behavior
I would expect all three examples to return
[1,2,3,4,5]
(in the applicable datastructure), as slicing beyond the beginning of the list in Python tends to clamp to the beginning rather than loop back around to the end.Installed versions