DistanceMatrix.
between
(from_, to_, allow_overlap=False)[source]¶Obtain the distances between the two groups of IDs
State: Experimental as of 0.5.5.
Parameters: |
|
---|---|
Returns: | (i, j, value) representing the source ID (“i”), the target ID (“j”) and the distance (“value”). |
Return type: | pd.DataFrame |
Raises: |
|
Notes
Order of the return items is stable, meaning that requesting IDs [‘a’, ‘b’] is equivalent to [‘b’, ‘a’]. The order is with respect to the .ids attribute of self.
Example
>>> from skbio.stats.distance import DissimilarityMatrix
>>> dm = DissimilarityMatrix([[0, 1, 2, 3, 4], [1, 0, 1, 2, 3],
... [2, 1, 0, 1, 2], [3, 2, 1, 0, 1],
... [4, 3, 2, 1, 0]],
... ['A', 'B', 'C', 'D', 'E'])
>>> dm.between(['A', 'B'], ['C', 'D', 'E'])
i j value
0 A C 2.0
1 A D 3.0
2 A E 4.0
3 B C 1.0
4 B D 2.0
5 B E 3.0