I have a function which takes two inputs and returns a float e.g. my_func('A', 'B') = 0.5
.
I have a list of possible inputs: x = ['A', 'B', 'C', 'D', 'E', 'F']
.
I want to produce a square matrix (in this case 6 by 6) where the values of each cell is the result of the function with the corresponding row and column values as inputs. Note my_func('A', 'A') = 1
and my_func('A', 'B') = my_func('B', 'A')
I have tried pandas.crosstab(x, x, aggfunc = my_func)
but this doesn't work.