Characters named A, B, C, D, E play tons of games against each other for which I record their final result. Characters can also play against themselves. My DataFrame looks like this :
df = pd.DataFrame(data = [['A', 'B'], ['D', 'D'], ['E', 'A'], ['C', 'D'], ['E', 'D']],
columns = ['Winner', 'Loser'])
I would like to build a win rate Matrix, where my columns are A, B, C, D, E, my rows index are also A, B, C, D, E, and each cell would be the win rate of the index vs the column. The diagonal would be mathematically 50%.
I don't have the right thinking to convert the dataframe to this matrix and would appreciate some help. Also note that I can't start aggregating the df to winrates with a casual groupby('Winner') as {['A', 'B'], ['A', 'B'], ['B', 'A']} should also be grouped together as a 66% winrate for A with a total of 3 games played.