Skip to content

Column.is_in #159

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

Closed
MarcoGorelli opened this issue May 2, 2023 · 2 comments · Fixed by #160
Closed

Column.is_in #159

MarcoGorelli opened this issue May 2, 2023 · 2 comments · Fixed by #160

Comments

@MarcoGorelli
Copy link
Contributor

MarcoGorelli commented May 2, 2023

In the last call it was brought up that perhaps we should add Column.is_in

This can be achieved with the existing Standard methods:

result = column == values[0]
for value in values[1:]:
    if math.isnan(value):
        result |= column.isnan()
    elif value is namespace.null:
        result |= column.isnull()
    else:
        result |= column == value

so it really just be a convenience method. No objections to adding it anyway

@jorisvandenbossche
Copy link
Member

Apart from convenience, an additional reason that many DataFrame libraries have a function like this is also because it can be much more performant with a custom implementation, compared to the generic code above.

(also, your code needs a slight edit to support NaN/null as first value, so probably it would be easiest to start result with an all-False column)

@MarcoGorelli
Copy link
Contributor Author

right, thanks - OK, I'll make a PR then, this probably needs to be included

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants