skbio.table.Table.exists#

Table.exists(id, axis='sample')[source]#

Returns whether id exists in axis

Parameters:
id: str

id to check if exists

axis{‘sample’, ‘observation’}, optional

The axis to check

Returns:
bool

True if id exists, False otherwise

Examples

>>> import numpy as np
>>> from biom.table import Table

Create a 2x3 BIOM table:

>>> data = np.asarray([[0, 0, 1], [1, 3, 42]])
>>> table = Table(data, ['O1', 'O2'], ['S1', 'S2', 'S3'])

Check whether sample ID is in the table:

>>> table.exists('S1')
True
>>> table.exists('S4')
False

Check whether an observation ID is in the table:

>>> table.exists('O1', 'observation')
True
>>> table.exists('O3', 'observation')
False