Here I have a table (it is really large, I just give a simplified example)
import pandas as pd
indices = (1,2,3,4)
columns = ["id", "height1", "height2", "height3"]
data = (["xxx1", 1, 2, 3], ["xxx2", 4, 5, 6], ["xxx3", 7, 8, 9], ["xxx4", 10, 11, 12])
df = pd.DataFrame(data, index = indices, columns = columns)
df
However, what should I do if I want to this dataframe to be displayed in this way? I tried to use groupby(id) and then unstack() but failed.
Any help or hint is welcome
id height score
xxx1 height1 1
xxx1 height2 2
xxx1 height3 3
xxx2 height1 4
xxx2 height2 5
.
.
.
xxx4 height3 12
