Hello let say I have a df such as :
G1 G2 VALUE
SP1 SP2 1
SP1 SP3 2
SP1 SP4 3
SP2 SP3 4
SP2 SP4 5
SP3 SP4 6
how can I get a the data as square ? (i.e., have the same number of rows and columns)
with something like
data = [[0, 1, 2, 3],
[1, 0, 4, 5],
[9, 10, 0, 8, 7],
[2, 4, 0, 6],
[3, 5, 6, 0]]
ids = ['SP1','SP2','SP3','SP4]
dm = DistanceMatrix(data, ids) (function from skbio package)
and get a matrix :
SP1 SP2 SP3 SP4
SP1 0 1 2 3
SP2 1 0 4 5
SP3 2 4 0 6
SP4 3 5 6 0
And if some of you are familiar with it, how can we also do the same thing but with a 1/2 matrix :
SP1 0
SP2 1 0
SP3 2 4 0
SP4 3 5 6 0
SP1 SP2 SP3 SP4
(here is mor for biopython) thanks a lot for your help
Other exemple
d = {'G1': ['SP1','SP2','SP2'], 'G2': ['SP3','SP3','SP1'],'VALUE' :[1,2,3]}
df = pd.DataFrame(data=d)
I should get :
SP1 0
SP2 3 0
SP3 1 2 0
SP1 SP2 SP3
and
SP1 0 3 1
SP2 3 0 2
SP3 1 2 0
SP1 SP2 SP3
I think this is what you're looking for, more or less:
In response to the edit to the question: