I have a Pandas Dataframe in the form of a matrix below which represents similarity scores between the elements (people) in the rows and the columns.
| | A | B | C |
|------------|-----------|---- ------|----------|
| D | 0.4 | 0.1 | 0.1 |
| E | 0.2 | 0.1 | 0.4 |
| F | 0.9 | 0.4 | 0.3 |
| G | 0.4 | 0.2 | 0.6 |
| H | 0.3 | 0.1 | 0.7 |
Further, I have a list of location identifiers for these elements.
A - London
B - Sydney
C - Paris
D - Paris
E - Delhi
F - London
G - Melbourne
H - Mumbai
I want to loop through the matrix and make the similarity score equal to 0 if the location is same between the two elements. In this example, I want to replace the intersection of A and F which is 0.9 and the intersection of D and C which is 0.1 with 0 each.
Thanks!
Edit:
The final expected output I am looking for is as below:
| | A | B | C |
|------------|-----------|---- ------|----------|
| D | 0.4 | 0.1 | 0.0 |
| E | 0.2 | 0.1 | 0.4 |
| F | 0.0 | 0.4 | 0.3 |
| G | 0.4 | 0.2 | 0.6 |
| H | 0.3 | 0.1 | 0.7 |