I have a pandas dataframe like this:
id value
1 25
2 40
3 30
Ideally I would like to convert it to this:
id value value_2 value_3
1 25 40 30
2 40 25 30
3 30 25 40
The logic behind the above conversation is that 2 extra columns containg the values for the other ids are added.
In the first row (id=1), value_2 = the value of the id=2, and value_3 = the value of id = 3.
In the second row (id=2), value_2 = the value of id=1, value_3 = the value of id=3
In the 3rd row (id=3), value_2 = the value of id=1, value_3 = the value of id=2
Is there a solution that allows me update all rows at once without having to iterate over each row, getting the value and then updating the dataframe of the other rows (one row at the time). Or what is the easiest solution to above challenge?
id_2andid_3associated withid? A dictionary? Another dataframe?