Skip to content Skip to sidebar Skip to footer

How To Convert Pair Lists (to Matrix) To Heat Map; Python

How to convert pair lists (to matrix) to heat map? Say, I have a Dataframe (pandas) like following ... a x 0.63 a y 1.00 a z 0.22 b z 0.13 b x 0.20 b y 0.58

Solution 1:

Something like the following would work, your df didn't have column names but I set them to be 'a','b','c' respectively:

In [20]:

df.pivot(index='a',columns='b').fillna(0)
Out[20]:
      c            
b     x     y     z
a                  
a  0.63  1.00  0.22
b  0.20  0.58  0.13
c  0.00  0.21  0.14

Post a Comment for "How To Convert Pair Lists (to Matrix) To Heat Map; Python"