Consider the first data structure. I need to transpose it as in the second structure.
I tried df.melt and df.pivot_table, but did not work.