-
Notifications
You must be signed in to change notification settings - Fork 125
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
exposing the fold
expressions from Polars
#911
Comments
It is not exposed (unless I missed it too!). I think it'd be a great addition. Though it looks like it'd be a good deal of work to add it so it might take a while.
If you want to ask on elixirforum.com, feel free to @- me and I can try to answer. My handle is the same as on GitHub. |
Oh, I didn't know we had |
So it seems there's They also have a few exprs pairs like Also looking over the docs, I think there's a lot of potential in exposing many of their exprs: |
Sorry, I got fold and reduce mixed up. If it is operating on the columns themselves, then we can probably add it to Explorer.Query directly. We already support column traversal via across/query. I am more interested in the reduce version that works within a single column. |
Yeah agreed! It'd be super useful in
If I'm reading this correctly (I've not confirmed it yet), then the df = DF.new(a: [1, 2, 3], b: [10, 20, 30], c: [100, 200, 300])
+--------------------------------------------+
| Explorer DataFrame: [rows: 3, columns: 3] |
+--------------+--------------+--------------+
| a | b | c |
| <s64> | <s64> | <s64> |
+==============+==============+==============+
| 1 | 10 | 100 |
+--------------+--------------+--------------+
| 2 | 20 | 200 |
+--------------+--------------+--------------+
| 3 | 30 | 300 |
+--------------+--------------+--------------+
mutate(df, sum: reduce_horizontal(cols(), 0, fn col, acc ->
col + acc
end))
+-------------------------------------------+
| Explorer DataFrame: [rows: 3, columns: 4] |
+----------+----------+----------+----------+
| a | b | c | sum |
| <s64> | <s64> | <s64> | <s64> |
+==========+==========+==========+==========+
| 1 | 10 | 100 | 111 |
+----------+----------+----------+----------+
| 2 | 20 | 200 | 222 |
+----------+----------+----------+----------+
| 3 | 30 | 300 | 333 |
+----------+----------+----------+----------+
Our comprehensions only make the same call to In fact, I wonder if we could make the |
We certainly could but perhaps @cigrainger has ideas on the API for this. @cigrainger, can we "fold" across columns in dplyr? |
The equivalent in dplyr would be accomplished with something like this: df
|> mutate(sum(c_across(starts_with("Bud"))) It's kind of gross, but quite similar to There used to be a |
Description
Is it possible to expose the folds API from Polars?
I have a problem that I think can be solved via that API (I'm not entirely sure, still a beginner with Explorer).
I can try to think of a version of my problem that I can publicly if needed.
Also, if this API is already exposed and I just missed it... please let me know 😅.
Thanks!
The text was updated successfully, but these errors were encountered: