skbio.table.Table.metadata_to_dataframe#
- Table.metadata_to_dataframe(axis)[source]#
Convert axis metadata to a Pandas DataFrame
- Parameters:
- axis{‘sample’, ‘observation’}
The axis to operate on.
- Returns:
- pd.DataFrame
A DataFrame indexed by the ids of the desired axis, columns by the metadata keys over that axis.
- Raises:
- UnknownAxisError
If the requested axis isn’t recognized
- KeyError
IF the requested axis does not have metadata
- TypeError
If a metadata column is a list or tuple, but is jagged over the axis.
Notes
Nested metadata (e.g., KEGG_Pathways) is not supported.
Metadata which are lists or tuples (e.g., taxonomy) are expanded such that each index position is a unique column. For instance, the key taxonomy will become “taxonomy_0”, “taxonomy_1”, etc where “taxonomy_0” corresponds to the 0th index position of the taxonomy.
Examples
>>> from biom import example_table >>> example_table.metadata_to_dataframe('observation') taxonomy_0 taxonomy_1 O1 Bacteria Firmicutes O2 Bacteria Bacteroidetes