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 | False | 1970-01-01 00:00:00.400 |
audio/002.wav | True | 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 | 8CT0DVc0UG |
audio/002.wav | 9wAKtlJaox |
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)