I have a data frame like the one below
And I want to transform it like following
Its a Double column index Transformation and I don't mind which of price/quantity, or date is the first level of column index. I think date is top and splits for price/quantity but couldn't create the table like this here.Its a data frame with about a million lines and all dates of year, so do you have any idea for the most efficient code to to this? Empty cells could also be 0s
SAMPLE DATA
CID | PROD_ID | PRICE | DATE | QUANTITY |
---|---|---|---|---|
123 | x | 1 | 31-12-20 | 5 |
123 | x | 1 | 1-1-21 | 5 |
123 | x | 1 | 2-1-21 | 7 |
123 | y | 2 | 2-1-21 | 11 |
789 | z | 5 | 1-1-21 | 22 |
256 | a | 4 | 1-1-21 | 9 |
324 | b | 4 | 1-1-21 | 16 |
789 | z | 5.5 | 2-1-21 | 22 |
324 | a | 4.5 | 2-1-21 | 23 |
324 | e | 8 | 2-1-21 | 3 |