-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Search for an item in a list (or array), part 2 #20626
Comments
I, personally, think both Option 1A/1B and Option 2 have their place, maybe under different names. Some names that might work.
As for implementation: Option 2 can be implemented with |
Option 1:
Option 1B:
Option 2:
|
@orlp are you suggesting those as an implementation strategy, or implying that it's not worth doing since it's already possible? |
@itamarst Neither (perhaps a hint of the latter), just showing how you could do it in today's Polars. |
I'm a bit late here, why isn't 1/1A just called For option 2, what about |
Description
Now that
Expr.index_of
is a thing, the next step is adding something similar to lists.Potential APIs
Thing is, there are actually multiple different multiple APIs people might want:
Option 1: For each list in the Series/Column, find the index of the value in that list:
This is what @thobai requested when they filed #5503.
Option 1B: Like option 1, but supports a expression-oriented version
and search each list in the
list_of_floats
column for the corresponding value taken from thefloats
column. I think this is just a superset of option 1, and is what a G-Research user would like.Option 2: Find the index of the first list that contains the value:
Option 2 can be implemented on top of option 1, albeit inefficiently, so providing it as an exposed feature is an optimization, not a necessity. Perhaps this API if ever implemented should be called
.list.first_index_of()
.Initial questions for maintainers
.list.index_of()
, and option 2.list.first_index_of()
.amortized_iter()
seems like the easy approach?The text was updated successfully, but these errors were encountered: