Skip to content
New issue

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

feat(python): deprecate boolean mask for Series indexing #5075

Merged

Conversation

matteosantama
Copy link
Contributor

For consistency with #4342, I think we should soon drop support for Series.__getitem__ with a boolean mask. Instead, we should encourage users to use Series.filter.

If this looks ok, I will add the breaking change to the PR I am working on for #4924

(As a little bonus I've added overloaded Series.__getitem__. This change is a no-brainer.)

@github-actions github-actions bot added enhancement New feature or an improvement of an existing feature python Related to Python Polars labels Oct 2, 2022
@ritchie46
Copy link
Member

Good one. Thanks

@ritchie46 ritchie46 merged commit 982d4b5 into pola-rs:master Oct 2, 2022
@slonik-az
Copy link
Contributor

slonik-az commented Oct 2, 2022

we should encourage users to use Series.filter.

I am curious what would be a recommended ergonomic way of conditional assignment in place if ser[ser < 0] = 0 is not possible anymore? when/then/otherwise does not modify in place.

@ritchie46
Copy link
Member

when/then/otherwise does not modify in place.

It can be in place (from a memory perspective), if the memory is not shared.
ser[ser < 0] = 0 on the other hand can also be a full data copy (from a memory perspective).

I think we should keep allowing the __setitem__. But it will remain an anti-pattern. As it may still do a full data copy, and if you do those repeatedly it will be very expensive/single threaded , etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or an improvement of an existing feature python Related to Python Polars
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants