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

is_in for bool dtype #5642

Closed
Gabriel-ROBIN opened this issue Nov 26, 2022 · 1 comment · Fixed by #5682
Closed

is_in for bool dtype #5642

Gabriel-ROBIN opened this issue Nov 26, 2022 · 1 comment · Fixed by #5682
Labels
enhancement New feature or an improvement of an existing feature

Comments

@Gabriel-ROBIN
Copy link

Gabriel-ROBIN commented Nov 26, 2022

Problem description

I wish I could use polars to filter a Boolean column with the is_in function

Example:

import polars as pl

bool_value_to_filter_on = [True, None]

df = pl.DataFrame({'A' : [True, False, None]})
df.filter(pl.col('A').is_in(bool_value_to_filter_on))

Of course for this specific use case I could use df.filter(pl.col('A') | pl.col('A').is_null()), but in this case I can not work with a generic list of values.

@Gabriel-ROBIN Gabriel-ROBIN added the enhancement New feature or an improvement of an existing feature label Nov 26, 2022
@mkleinbort-ic
Copy link

mkleinbort-ic commented Nov 30, 2022

A quick hack while a full solution is found:

df.filter(pl.col('A').cast(int).is_in(bool_value_to_filter_on))

# Or 
df.filter(pl.col('A').cast(pl.Int8()).is_in(bool_value_to_filter_on))

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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants