-1

I'm struggling to find a solution, I want to transform the following dataframe:

d = {'Group': ['A', 'A', 'A', 'B', 'B', 'B'],
     'Person': ['Andrew', 'Carl', 'Karen' , 'Violet', 'Jennifer', 'Taylor'],
     'Value 1': [1000, 5000, 5000, 2000, 9000, 5000],
     'Value 2': [2000, 1000, 3000, 1000, 8000, 6000],
     'Value 3': [5000, 2000, 4000, 4000, 7000, 5000]}

df = pd.DataFrame(data=d)

Original dataframe:

Original dataframe

Into a dataframe with the following structure:

desired output

I've look in multiple posts, but the answer does not help me. Any contribution helps a lot, I need a dataframe as the desired output to use it as a table in Power BI.

Thank you

Andres Mitre
  • 589
  • 1
  • 9
  • 23
  • I found a solution, didn't know that there was function called melt. Thank you either bot, or person that marked as a duplicate. post: https://stackoverflow.com/questions/68961796/how-do-i-melt-a-pandas-dataframe – Andres Mitre May 19 '22 at 01:45

0 Answers0