Inconsistent behavior between slice() as an expression on a column and slice() on a Series/DataFrame #18553
Open
2 tasks done
Labels
bug
Something isn't working
needs decision
Awaiting decision by a maintainer
needs triage
Awaiting prioritization by a maintainer
python
Related to Python Polars
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
The text was updated successfully, but these errors were encountered: