I have a pandas dataframe with the distances between names like this:
| name1 | name2 | distance |
|---|---|---|
| Peter | John | 3.4 |
| John | James | 2.3 |
| James | Peter | 1.4 |
I need to convert it to a distance matrix like this. (The distances with the same names (that are always 0) are not in the original dataframe):
| matrix | John | Peter | James |
|---|---|---|---|
| John | 0 | 3.4 | 2.3 |
| Peter | 3.4 | 0 | 1.4 |
| James | 2.3 | 1.4 | 0 |
Any help?
Thank you!