Working with a database

Accessing data

Annotation labels can be accessed by the audformat.Table.get() method:

import audformat.testing


db = audformat.testing.create_db()
table = db["files"].get()
# Short for:
# table = db.tables["files"].get()

Which returns the following pandas.DataFrame:

table.iloc[0:2, 0:2]
bool date
file
audio/001.wav True 1970-01-01 00:00:00.850
audio/002.wav <NA> NaT

Or you can directly access a column with audformat.Column.get():

column = db["files"]["string"].get()
# Short for:
# column = db.tables["files"].columns["string"].get()

Which results in the following pandas.Series:

column[0:2]
string
file
audio/001.wav UiXzjmvo8R
audio/002.wav 8AXT6TzKYO

For more information on how to access or add data have a look at the code examples in the table specification.

Changing referenced files

To convert to absolute file paths in all tables, do:

import os


db.map_files(os.path.abspath)