Given a square pandas DataFrame of the following form:
a b c
a 1 .5 .3
b .5 1 .4
c .3 .4 1
How can the upper triangle be melted to get a matrix of the following form
Row Column Value
a a 1
a b .5
a c .3
b b 1
b c .4
c c 1
#Note the combination a,b is only listed once. There is no b,a listing
I'm more interested in an idiomatic pandas solution, a custom indexer would be easy enough to write by hand...
Thank you in advance for your consideration and response.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…