-
Notifications
You must be signed in to change notification settings - Fork 368
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
expression functors (in particular: over
)
#3377
Comments
Yes - my point was about what is your proposal for these cases. In particular:
(maybe you are not clear what to do - it is OK then, but we must clearly see how to combine the proposal with the whole ecosystem) |
I have not thought out all the edge cases yet, but I will try to get a list of examples for these scenarios (and then bikeshed the actual api) at least in the basic case of
should all be equal |
Note that |
actually, sorry, could you help me create such an edge case that may be ambiguous? maybe this is a naive answer, but I am thinking that in the same way for there is already an error when the column lengths from
as an alternate API showerthought, since
etc |
Here is a problematic example:
and now it is unclear what should be done.
but how to link them? Note that if Note that things would yet be more complicated if the Your examples work and are clear what to do because you work with:
And when we combine these two conditions indeed things are clear how they should work. |
so, I would say this should error for the same reason that this does.
if one consequence, if I understand myself correctly lol, would be
is a no-op, equivalent to |
I think in terms of behavior, this does more or less everything I'm imagining (although obviously the implementation is inefficient and the API is pretty kludgy)
|
You opened the discussion with the polars Note that the design of I need to think about it more. The mental problem I have is that while I see the need for |
Maybe this shouldn't be allowed with In terms of syntax, the most consistent extension of the current API I can think of would be |
totally agreed. in fact, part of the whole reason to want . Another thing to consider with the API is composition of potentially multiple expr functors (hopefully not too ambitious), with another prominent example being
and btw, the reason I am calling these "functors" is because in fact they really can take arbitrary expressions, like so
|
As for functors - I think it will be too hard to add them. Our API is too different. Such things were designed to be chained. As for the syntax:
would be re-written as:
so maybe it would be clearer to use the following syntax:
(as then it would be fully clear that |
I still think my preferred syntax, if possible, would be with a pipe, both to avoid an extra layer of function nesting and to avoid the classic problem of having to jump the cursor back to add the
possibly as a curried version of
read as "transform
I also prefer this over @nalimilan 's proposed syntax since I feel like it is somewhat of a rule that all the columns in the transformation must appear in the first of the an attempt to enumerate the questions/decisions to be made:
. .
ok, fair enough (especially for the general case). but wouldn't this be nice for some more "simple" compositions of
|
Let us focus on the syntax. I will answer the rest of the issues once this is settled (as this will be a consequence). Using So I understand the proposal is to have:
which is equivalent to:
to be rewritten as:
|
yes, that looks great IMO. |
pasted from slack:
consider the following type of expr
this is fine in isolation, but is a little unwieldy when embedded in a select list of multiple transformations at once. technically, the below works but is obviously not idiomatic...
polars has
.over
which is essentially an expr functor(expr, col) --> expr
, so something like this could be expressed asI'm wondering if such a feature / expr transformation like over (which I use frequently) could be implemented in DataFrames ? (or if it exists and I haven't found it yet)
reply by bkamins:
The text was updated successfully, but these errors were encountered: