i'm doing a matrix calculation using pandas in python.

my raw data is in the form of list of strings(which is unique for each row).

```
id     list_of_value
0      ['a','b','c']
1      ['d','b','c']
2      ['a','b','c']
3      ['a','b','c']

```

i have to do a calculate a score with one row and against all the other rows

score calculation algorithm:

```
Step 1: Take value of id 0: ['a','b','c'],
Step 2: find the intersection between id 0 and id 1 , 
        resultant = ['b','c']
Step 3: Score Calculation => resultant.size / id(0).size

```

repeat step 2,3 between id 0 and id 1,2,3, similarly for all the ids.

Create N \* N matrix:

```
-  0    1    2  3
0  1    0.6  1  1
1  0.6  1    1  1 
2  1    1    1  1
3  1    1    1  1

```

At present i'm using the pandas dummies approach to calculate the score:

```
s = pd.get_dummies(df.list_of_value.explode()).sum(level=0)
s.dot(s.T).div(s.sum(1))

```

but there is an repetition in calculation after the diagonal of the matrix, the score calculation till diagonal is sufficient. for eg:

calculation of score of ID 0, will be only till ID(row,column) (0,0), score for ID(row,column) (0,1),(0,2),(0,3) can be copied from ID(row,column) (1,0),(2,0),(3,0).

Detail on the calculation:
[![matrix sample](https://i.stack.imgur.com/vXSIJ.png)](https://i.stack.imgur.com/vXSIJ.png)
i need to calculate till the diagonal, that is **till** the yellow colored box(the diagonal of matrix), the white values are already calculated in the green shaded area (for ref), i just have to transpose the green shaded area to white.

how can i do this in pandas?