I have a pyspark dataframe that looks like this:
Date | Bought | Delivered | Returned |
---|---|---|---|
07/05/2021 | 1054 | 1036 | 13 |
07/06/2021 | 2036 | 2015 | 21 |
I need it to ultimately look like this:
Date | Step | Total |
---|---|---|
07/05/2021 | Bought | 1054 |
07/05/2021 | Delivered | 1036 |
07/05/2021 | Returned | 13 |
07/06/2021 | Bought | 2036 |
07/06/2021 | Delivered | 2015 |
07/06/2021 | Returned | 21 |
What I have tried so far is just making a bunch of different tables and then I union them at the end. But this takes too much time and I was hoping to find a much better way to do this. And since this is multiple columns the explode isn't what I am looking for. But that's all I can find here on stackoverflow so any help would be appreciated! :)