skbio.stats.distance.DissimilarityMatrix.to_data_frame#

DissimilarityMatrix.to_data_frame()[source]#

Create a pandas.DataFrame from this DissimilarityMatrix.

Returns:
pd.DataFrame

pd.DataFrame with IDs on index and columns.

Examples

>>> from skbio import DistanceMatrix
>>> dm = DistanceMatrix([[0, 1, 2],
...                      [1, 0, 3],
...                      [2, 3, 0]], ids=['a', 'b', 'c'])
>>> df = dm.to_data_frame()
>>> df
     a    b    c
a  0.0  1.0  2.0
b  1.0  0.0  3.0
c  2.0  3.0  0.0