I'm trying to create a matrix to show the differences between the rows in a Pandas data frame.
import pandas as pd
data = {'Country':['GB','JP','US'],'Values':[20.2,-10.5,5.7]}
df = pd.DataFrame(data)
I would like this:
  Country  Values
0      GB    20.2
1      JP   -10.5
2      US     5.7
To become something like this (differences going vertically):
  Country     GB     JP     US
0      GB    0.0  -30.7   14.5
1      JP   30.7    0.0   16.2
2      US   14.5  -16.2    0.0
Is this achievable with built-in function or would I need to build a loop to get the desired output? Thanks for your help!