I have this dataframe:
df = pd.DataFrame({'Gene': ['419', '1036', '1167', '1629'],
'Myob': [0.261, 1.010, -0.534, 1.412],
'Myob_Ind': [0.901, 0.525, 2.588, 1.825],
'Cluster': [0, 0, 0, 0]})
Which looks like:
Gene Myob Myob_Ind Cluster
0 419 0.261 0.901 0
1 1036 1.010 0.525 0
2 1167 -0.534 2.588 0
3 1629 1.412 1.825 0
I want to reshape it so it looks like this:
Gene Z-Scores Cell Lines Cluster
0 419 0.261 Myob 0
1 419 0.901 Myob_Ind 0
2 1036 1.010 Myob 0
3 1036 0.525 Myob_Ind 0
4 1167 -0.534 Myob 0
5 1167 2.588 Myob_Ind 0
6 1629 1.412 Myob 0
7 1629 1.825 Myob_Ind 0
My goal is to add additional cell lines, like from neutrophils or adipose, and plot the z-scores using boxplots, but I need the data in this form to do that. The order of the genes/cell lines doesn't matter as long as they match their respective z-scores. I am having trouble with pd.melt and pd.concat which leaves me unsure of their correct use.