This is my current table:
| User Id | Product | Amount 1 | Amount 2 | Amount 3 |
|---|---|---|---|---|
| 1 | A | 100 | 200 | 300 |
| 1 | B | 200 | 300 | 400 |
| 2 | A | 500 | 600 | 700 |
This is the output I'm looking for:
| User Id | Amount 1 | Amount 2 | Amount 3 |
|---|---|---|---|
| 1 | {"A": 100, "B": 200} | {"A": 200, "B": 300} | {"A": 300, "B": 400} |
| 2 | {"A": 500} | {"A": 600} | {"A": 700} |
I understand that I should be using a User Defined Aggregate Function, but am unable to understand how to implement them via PySpark.
Any help would be greatly appreciated.