I am trying to bring the pandas dataframe from wide to long but I cannot find a good way to do it. Any suggestion to do this through pandas?
data = {'colour':["red", "blue", "yellow", "red", "yellow"],
'apple':[1, 2, 4, 5, 6],
'organge': [3, 4, 5, 7, 8],
'watermelon': [7, 8, 9, 1, 0]}
df = pd.DataFrame(data)
df
colour apple organge watermelon
0 red 1 3 7
1 blue 2 4 8
2 yellow 4 5 9
3 red 5 7 1
4 yellow 6 8 0
Expected result:
fruit red blue yellow
0 apple 6 2 10
1 organge 10 4 13
2 watermelon 8 8 9