0

I have a DataFrame that looks more or less like this:

key_1 key_2 value angle
A B 10 1
A C 15 1
D F 12 1
A B 11 2
T R 17 2
D G 14 2
D G 19 3
B N 18 3
D F 13 3

My goal is to group the values by the column angle and turn the long table into a wide one taking into account that I also have two columns (key_1 and key_2) that have to be considered when placing the values in correct cells. I tried to work with .pivot, but this is not what I need. I wanted the final table to look like this:

key_1 key_2 1 2 3
A B 10 11 0
A C 15 0 0
D F 12 0 13
T R 0 17 0
D G 0 14 19
B N 0 0 18
D F 0 0 13

I don't know what are the steps to take to make this work.

Anavae
  • 482
  • 1
  • 3
  • 13

0 Answers0