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 (see audformat.Scheme) and a rater (see audformat.Rater).

Parameters

Examples

>>> Column(scheme_id="emotion")
{scheme_id: emotion}

__eq__()

Column.__eq__(other)[source]

Compare if column equals another column.

Return type

bool

description

Column.description

Description

dump()

Column.dump(stream=None, indent=2)

Serialize object to YAML.

Parameters
  • stream – file-like object. If None serializes to string

  • indent (int) – indent

Return type

str

Returns

YAML string

from_dict()

Column.from_dict(d, ignore_keys=None)

Deserialize object from dictionary.

Parameters
  • d (dict) – dictionary of class variables to assign

  • ignore_keys (Optional[Sequence[str]]) – variables listed here will be ignored

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 index to get a subset.

Examples are provided with the table specifications.

Parameters
  • index (Optional[Index]) – index conform to table specifications

  • copy (bool) – return a copy of the labels

  • map (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 speaker

  • as_segmented (bool) – if set to True and column has a filewise index, the index of the returned column will be converted to a segmented index. start will be set to 0 and end to NaT or to the file duration if allow_nat is set to False. If column belongs to a miscellaneous table, this and the following arguments have no effect

  • allow_nat (bool) – if set to False, end=NaT is replaced with file duration

  • root (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. If None audformat.Database.root is used. Only relevant if allow_nat is set to False

  • num_workers (Optional[int]) – number of parallel jobs. If None will be set to the number of processors on the machine multiplied by 5

  • verbose (bool) – show progress bar

Return type

Series

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

meta

Column.meta

Dictionary with meta fields

rater

Column.rater

Rater object.

Returns

rater object or None if not available

rater_id

Column.rater_id

Rater identifier

scheme

Column.scheme

Scheme object.

Returns

scheme object or None if not available

scheme_id

Column.scheme_id

Scheme identifier

set()

Column.set(values, *, index=None)[source]

Set labels.

By default, all labels of the column are replaced, use index to set a subset. If columns is assigned to a Scheme values 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

table

Column.table

Table object.

Returns

table object or None if not assigned yet

to_dict()

Column.to_dict()

Serialize object to dictionary.

Return type

dict

Returns

dictionary with attributes