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

Clarification / Question: Dataframe.filter AND/OR mask? #56

Closed
drowzy opened this issue Sep 7, 2021 · 2 comments · Fixed by #57
Closed

Clarification / Question: Dataframe.filter AND/OR mask? #56

drowzy opened this issue Sep 7, 2021 · 2 comments · Fixed by #57
Labels
kind:feature New feature or request

Comments

@drowzy
Copy link
Contributor

drowzy commented Sep 7, 2021

I see in the docs that one can filter using a mask:

df = Explorer.DataFrame.from_map(%{a: ["a", "b", "c"], b: [1, 2, 3]})
Explorer.DataFrame.filter(df, Explorer.Series.greater(df["b"], 1))

#Explorer.DataFrame<
[rows: 2, columns: 2]
a string ["b", "c"]
b integer [2, 3]
>

How does one create an AND/OR mask? I could compute them manually and use a list, but is there a better way?
Sort of what I'm looking for:

df = Explorer.DataFrame.from_map(%{a: ["a", "b", "c"], b: [1, 2, 3]})
mask = Explorer.Series.or(Explorer.Series.equal(df["b"], 1), Explorer.Series.equal(df["b"], 3))

Explorer.DataFrame.filter(df, mask)

#Explorer.DataFrame<
[rows: 2, columns: 2]
a string ["b", "c"]
b integer [1, 3]
>
@cigrainger
Copy link
Member

There's not anything built in right now, but I think something like this is a great idea. I think polars has something for this. I'll look into it, but would also be happy to accept a PR. :)

@drowzy
Copy link
Contributor Author

drowzy commented Sep 8, 2021

Sure! I'll submit a PR :)

@cigrainger cigrainger added the kind:feature New feature or request label Sep 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:feature New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants