Column¶
- class audformat.Column(*, scheme_id=None, rater_id=None, description=None, meta=None)[source]¶
Table column.
Represents a table column (see
audformat.Table) and optionally links it to a scheme (seeaudformat.Scheme) and a rater (seeaudformat.Rater).- Parameters
Examples
>>> Column(scheme_id="emotion") {scheme_id: emotion}
dump()¶
from_dict()¶
get()¶
- Column.get(index=None, *, map=None, copy=True, as_segmented=False, allow_nat=True, root=None, num_workers=1, verbose=False)[source]¶
Get labels.
By default, all labels of the column are returned, use
indexto get a subset.Examples are provided with the table specifications.
- Parameters
index (
Optional[Index]) – index conform to table specificationscopy (
bool) – return a copy of the labelsmap (
Optional[str]) – map scheme or scheme field to column values. For example if your column holds speaker IDs and is assigned to a scheme that contains a dict mapping speaker IDs to age entries,map='age'will replace the ID values with the age of the speakeras_segmented (
bool) – if set toTrueand column has a filewise index, the index of the returned column will be converted to a segmented index.startwill be set to0andendtoNaTor to the file duration ifallow_natis set toFalse. If column belongs to a miscellaneous table, this and the following arguments have no effectallow_nat (
bool) – if set toFalse,end=NaTis replaced with file durationroot (
Optional[str]) – root directory under which the files are stored. Provide if file names are relative and database was not saved or loaded from disk. IfNoneaudformat.Database.rootis used. Only relevant ifallow_natis set toFalsenum_workers (
Optional[int]) – number of parallel jobs. IfNonewill be set to the number of processors on the machine multiplied by 5verbose (
bool) – show progress bar
- Return type
- Returns
labels
- Raises
FileNotFoundError – if file is not found
RuntimeError – if column is not assigned to a table
ValueError – if trying to map without a scheme, or from a scheme that has no labels, or from a scheme that has only a list of labels, or to a non-existing field
set()¶
- Column.set(values, *, index=None)[source]¶
Set labels.
By default, all labels of the column are replaced, use
indexto set a subset. If columns is assigned to aSchemevalues will be automatically converted to match its dtype.Examples are provided with the table specifications.
- Parameters
- Raises
RuntimeError – if column is not assign to a table
ValueError – if trying to set values of a filewise column using a segmented index
ValueError – if values cannot be converted to match the schemes dtype