From the following Pandas dataframe (actually a distance matrix):
foo foo bar bar spam spam
foo 0.00 0.35 0.83 0.84 0.90 0.89
foo 0.35 0.00 0.86 0.85 0.92 0.91
bar 0.83 0.86 0.00 0.25 0.88 0.87
bar 0.84 0.85 0.25 0.00 0.82 0.86
spam 0.90 0.92 0.88 0.82 0.00 0.50
spam 0.89 0.91 0.87 0.86 0.50 0.00
I was trying to create lists deriving from all combinations of ['foo','bar','spam']
, to obtain the following lists with unique values:
foo_foo = [0.35]
foo_bar = [0.83,0.84,0.86,0.85]
foo_spam = [0.90,0.89,0.92,0.91]
bar_bar = [0.25]
bar_spam = [0.88,0.87,0.82,0.86]
spam_spam = [0.50]
I used df.get_values and iterrows without success, and also these answers How to get a value from a cell of a data frame? and pandas: how to get scalar value on a cell using conditional indexing were not useful.
Is there a way to afford that? Any help would be appreciated