I have checked a lot of melt
related questions here but none of them work for what I want to do.
I have this dataframe:
And I want to melt it to this shape:
I have tried a lot of different variations of melt & pivot from stack overflow.
If this is a duplicate question let me know because I wasn't able to find a solution.
My test dataframe:
stack.to_dict()
{'A': {0: 1, 1: 5}, 'B': {0: 2, 1: 6}, 'C': {0: 3, 1: 7}, 'D': {0: 4, 1: 8}}