I have pandas data frame as follows, pandas data frame:
print (df)
Unnamed: 0 P1 P2 P3 P4 P5 P6
0 P1 0 245 102 73 275 212
1 P2 32 0 91 181 216 66
2 P3 88 78 0 65 268 32
3 P4 111 39 225 0 103 86
4 P5 265 271 116 279 0 110
5 P6 258 129 247 191 159 0
I need to convert this into a dictionary-like below,
distance = {('P1','P1'):0,('P1','P2'):245,('P1','P3'):102,('P2','P1'):32}