Skip to content

Add is-not-in to complement is-in #7024

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

Open
kiil opened this issue Nov 6, 2022 · 0 comments
Open

Add is-not-in to complement is-in #7024

kiil opened this issue Nov 6, 2022 · 0 comments
Labels
dataframe Work related to the polars dataframe implementation enhancement New feature or request

Comments

@kiil
Copy link

kiil commented Nov 6, 2022

Related problem

I am trying to remove stopwords from a tokenized corpus.

Removing all words except the stopwords is easily achievable:

let stopwords = (open stopwords.txt | lines | into df)
let corpus = (open corpus.txt | split words | into df)
let mask = ($corpus | is-in $stopwords)
let result = ($corpus | filter-with $mask)

But I need the opposite, to get rid of the stopwords and keep the other words.

Describe the solution you'd like

The elegant solution would be a new command called is-not-in

(I think this is also termed antijoin in other systems)

An example:

let stopwords = (open stopwords.txt | lines | into df)
let corpus = (open corpus.txt | split words | into df)
let mask = ($corpus | is-not-in $stopwords)                <------ requested feature
let tidy = ($corpus | filter-with $mask)

then $tidy would contain the words in $corpus minus the words in $stopwords

Describe alternatives you've considered

I've been trying to "negate" the mask, so it finds false instead of true - since that would also work, but I have found no way to negate a boolean in filter-with.

EDIT:

let tidy = ($corpus | filter-with ($mask | df-not))

can be used, so is-not-in is more of a "nice to have", I guess.

Additional context and details

No response

@kiil kiil added the enhancement New feature or request label Nov 6, 2022
@fdncred fdncred added the dataframe Work related to the polars dataframe implementation label Nov 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dataframe Work related to the polars dataframe implementation enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants