Skip to main content
`Ctrl`+`K`

# skbio.stats.distance.PairwiseMatrix.between

PairwiseMatrix.between(from_, to_, allow_overlap=False)

  Obtain the pairwise values between the two groups of IDs.

  Parameters:
    from_Iterable of str

      The IDs to obtain values from.

    to_Iterable of str

      The IDs to obtain values to.

    allow_overlap bool, optional

      If True, allow overlap in the IDs of from and to (which would in effect be collecting the within distances). Default is False.

  Returns:
    pd.DataFrame

      (i, j, value) representing the source ID (“i”), the target ID (“j”) and the value between them (“value”).

  Raises:
    MissingIDError

      If an ID(s) specified is not in the matrix.

  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.

  Examples

      >>> from skbio.stats.distance import PairwiseMatrix
      >>> dm = PairwiseMatrix([[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