-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
selectors
should support slicing columns
#15963
Comments
If you know what fields you want, why do you need a selector? Why not use a simple |
@aut0clave They want to extract the "range of columns" I believe first/last are the only selectors that are "positional" >>> cs.first().meta.serialize()
'{"Nth":0}' There is no >>> df.select( pl.Expr.deserialize( io.StringIO("""{"Nth":3}""") ) )
shape: (3, 1)
┌───────┐
│ Mango │
│ --- │
│ i64 │
╞═══════╡
│ 4 │
│ 10 │
│ 90 │
└───────┘
From what I can tell, there is nothing that goes the other way, i.e. |
@cmdlineluser i'd assume there was a way to get the positions of the column names (maybe grab the positions via list.index from python and pass it to the rust end). dont know much about the internal implementation, happy to learn. I'd also suggest, if the team feels like this is a worthwhile addition, that the slicing be limited to column names only (numeric positions should not be supported) |
FYI: until we are actually evaluating a lazy query plan we may not know the position of all of the columns (eg: expanding a struct, or evaluating earlier selectors). Consequently we can't precompute and pass-down, because it's only at the lower level that we would know the answer (selectors are dynamic, evaluating internally at the point they are invoked) ;) Offering index-based selection doesn't seem like a bad idea (we currently only support selection by name/dtype and the special cases of first/last, as noted by @cmdlineluser), but would need some internal additions to be possible 🤔 |
@cmdlineluser so something like |
@alexander-beedie is the person to ask. (they created |
Probably |
FYI, forgot to update this issue, but we do now have a new |
Thanks @alexander-beedie. Looks good. Safe to assume that slicing with labels may be implemented at a future date? |
Probably, but no timeline; the 1.0 (and a few quick point releases to address any related issues) has priority at the moment. And I'm on vacation for the next two weeks ;) |
Description
Hi team. I would like to suggest adding a
slice
method to the selectors class, where users can select a slice of columns :The slicing syntax can be :
The text was updated successfully, but these errors were encountered: