We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
This is the current behavior of pl.Series(["abcd"]).str.slice(i, 2), and the other (non-string) slice operations behave similarly:
pl.Series(["abcd"]).str.slice(i, 2)
-7 ab -6 ab -5 ab 0 ab -4 ab 1 bc -3 bc 2 cd -2 cd 3 d -1 d 4 5
This inconsistency between the left-hand-side and right-hand-side should be fixed, and instead we'd have the following behavior:
-7 -6 -5 a 0 ab -4 ab 1 bc -3 bc 2 cd -2 cd 3 d -1 d 4 5
To translate from Polars-style offset, length to Python's start_index, end_index the following logic should apply consistently everywhere:
offset
length
start_index
end_index
# Signed arithmetic (allows negatives). start_idx = len(s) + offset if offset < 0 else offset stop_idx = start_idx + length # Clamp negatives / out-of-bounds. def clamp(x, lo, hi): return max(lo, min(x, hi)) start_idx = clamp(start_idx, 0, len(s)) stop_idx = clamp(stop_idx, 0, len(s))
The text was updated successfully, but these errors were encountered:
orlp
Successfully merging a pull request may close this issue.
This is the current behavior of
pl.Series(["abcd"]).str.slice(i, 2)
, and the other (non-string) slice operations behave similarly:This inconsistency between the left-hand-side and right-hand-side should be fixed, and instead we'd have the following behavior:
To translate from Polars-style
offset
,length
to Python'sstart_index
,end_index
the following logic should apply consistently everywhere:The text was updated successfully, but these errors were encountered: