filter(): %in% %notin% | & operators and slice() operation
See original GitHub issueHey @machow , I hope you are doing well.
I have some questions and suggestions regarding filter()
that I would like to discuss here if I may.
(1) Enable logical operators &
, |
, or and
, or
inside filter(). Right now I could not find a way to use or
logic, for example: filter(_.x>2 | ._x==0.5)
(2) Would you consider implementing %in%
(and %notin%
) operators to do something like filter(_.country %in% ['Australia', 'Ireland'])
? Currently we have to rely on pandas syntax filter(_.country.isin(["Australia","Ireland"])
(3) Since siuba
currently does not have slice()
, is there an easy way to accomplish the same task using filter()
?
Thank you
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
How to Use “not in” operator in Filter - R-bloggers
How to Use “not in” operator in Filter, To filter for rows in a data frame that is not in a list of...
Read more >filter - MuleSoft Documentation
If it returns false for a value or index in the array, that item gets filtered out of the output. If there are...
Read more >Built-in template tags and filters - Django documentation
This document describes Django's built-in template tags and filters. ... key named 'items' , data.items will return data['items'] instead of data.items() .
Read more >Indexing, Slicing and Subsetting DataFrames in Python
Query / select a subset of data using a set of criteria using the following operators: == , != , > , <...
Read more >Array.prototype.slice() - JavaScript - MDN Web Docs
The slice() method returns a shallow copy of a portion of an array into a new array ... If start >= array.length ,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The
in
operator relies on the__contains__(a, b)
method being defined for the object on the right-hand side. This means that you would need to create asiuba
aware wrapper class for sequences.The wrapper would define the
__contains__(a, b)
method.The final syntax would be:
I’m sure you can think of a better name for the wrapper… (This is how you can do it. I don’t know if you should do it!)
@davidwales unfortunately the
__contains__
method requires that you return a Boolean 😕. AFAIK siuba’s symbolic class can’t handle__iter__
,__contains__
, or the keywordsand
,or
(these keywords throw errors for pandas and bumpy arrays too for the same reason).