-
Notifications
You must be signed in to change notification settings - Fork 644
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
Combine multiple columns when aggregating #1214
Comments
There is nothing that can do all that in one step. You should probably
1. do the calculation first, to create a reduction column.
2. Then look at the melt and cast operations. Melt can convert rows to
columns for some use cases.
3. Then convert the reduction column to a string column using
asStringColumn (or something like that), and finally
4. Create a new column that combines that with the country name text
using a string column operation. This may take an extra step if you want
the country name in square brackets
…On Wed, May 24, 2023 at 9:47 AM Julien Carrau ***@***.***> wrote:
I didn't find a way to do it while aggregating. Instead I first combine
the columns I want and then I aggregate which is quite longer to code.
For instance if I have a table with a column containing items with prices
and reductions in different countries and I want to group by item id. The
aggregation I want is for instance a string join with the reduced price and
the country.
| Item Id | Price | Reduction | Country |
| 1 | 10 | 0.25 | India |
| 1 | 20 | 0.1 | UK |
And I want to have the result as:
| Item Id | Aggregated
| 1 | 7.5 [India], 18 [UK]
So I'm looking for an aggregation method about to take multiple columns
with different types and to combine all of them in one column.
Thanks in advance for your help, the library is really well done and very
fast!
—
Reply to this email directly, view it on GitHub
<#1214>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AA2FPAWRBNMYK4LDWEJ7JBTXHYGORANCNFSM6AAAAAAYNNIFQ4>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Ok! Exactly like I did. Thank you for your answer, I was just wondering if I was doing it the right way :) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I didn't find a way to do it while aggregating. Instead I first combine the columns I want and then I aggregate which is quite longer to code.
For instance if I have a table with a column containing items with prices and reductions in different countries and I want to group by item id. The aggregation I want is for instance a string join with the reduced price and the country.
| Item Id | Price | Reduction | Country |
| 1 | 10 | 0.25 | India |
| 1 | 20 | 0.1 | UK |
And I want to have the result as:
| Item Id | Aggregated
| 1 | 7.5 [India], 18 [UK]
So I'm looking for an aggregation method about to take multiple columns with different types and to combine all of them in one column.
Thanks in advance for your help, the library is really well done and very fast!
The text was updated successfully, but these errors were encountered: