I have a JSON data like:
a={('A', 'B'): 0.8333333333333334, ('A', 'C'): 0.5, ('B', 'C'): 0.625}
I need to draw a heatmap based on that data set. but the dataframe I obtained by
df=pd.DataFrame(a,index=['value']).T.reset_index()
is like:
and this seems can not be used to draw a heat map. And the result dataframe should be looked like this:
df=pd.DataFrame({'A':{'A':1,'B':0.83333,'C':0.5},'B':{'A':0.83333,'B':1,'C':0.625},'C':{'A':0.5,'B':0.625,'C':1}})
CodePudding user response:
Assuming:
a = {('A', 'B'): 0.8333333333333334, ('A', 'C'): 0.5, ('B', 'C'): 0.625}