Converting dataframe for heatmap /u/NitPo Python Education

I need to manipulate a dataframe to rapresent data in a specific way

ra={"smiles":["a","b","c","d"],"d1":[1,2,3,4],"d2":[5,6,7,8],"d3":[9,10,11,12]} ra=pd.DataFrame(data=ra) print(ra.head()) result = ra.pivot(index='smiles', columns='d1', values=['d1',"d2","d3"]) sns.heatmap(result, annot=True, fmt="g", cmap='viridis') plt.show() 

the resulting heatmap should have smiles as index and in each row the values in the same position in d1,d2,d3 as in the scheme below

a d1(0) d2(O) d3(0)

b d1(1) d2(1) d3(1)

c d1(2) d2(2) d3(2)

“d1” “d2” “d3”

I don’t understand how to correctly use pivot/heatmap

Thanks for any response!

submitted by /u/NitPo
[link] [comments]

​r/learnpython I need to manipulate a dataframe to rapresent data in a specific way ra={“smiles”:[“a”,”b”,”c”,”d”],”d1″:[1,2,3,4],”d2″:[5,6,7,8],”d3″:[9,10,11,12]} ra=pd.DataFrame(data=ra) print(ra.head()) result = ra.pivot(index=’smiles’, columns=’d1′, values=[‘d1′,”d2″,”d3″]) sns.heatmap(result, annot=True, fmt=”g”, cmap=’viridis’) plt.show() the resulting heatmap should have smiles as index and in each row the values in the same position in d1,d2,d3 as in the scheme below a d1(0) d2(O) d3(0) b d1(1) d2(1) d3(1) c d1(2) d2(2) d3(2) “d1” “d2” “d3” I don’t understand how to correctly use pivot/heatmap Thanks for any response! submitted by /u/NitPo [link] [comments] 

I need to manipulate a dataframe to rapresent data in a specific way

ra={"smiles":["a","b","c","d"],"d1":[1,2,3,4],"d2":[5,6,7,8],"d3":[9,10,11,12]} ra=pd.DataFrame(data=ra) print(ra.head()) result = ra.pivot(index='smiles', columns='d1', values=['d1',"d2","d3"]) sns.heatmap(result, annot=True, fmt="g", cmap='viridis') plt.show() 

the resulting heatmap should have smiles as index and in each row the values in the same position in d1,d2,d3 as in the scheme below

a d1(0) d2(O) d3(0)

b d1(1) d2(1) d3(1)

c d1(2) d2(2) d3(2)

“d1” “d2” “d3”

I don’t understand how to correctly use pivot/heatmap

Thanks for any response!

submitted by /u/NitPo
[link] [comments] 

Leave a Reply

Your email address will not be published. Required fields are marked *