annotations

function of dascore.core.annotation_loader source

annotations(
    source: dascore.core.annotations.AnnotationSet | str | os.PathLike | Any[AnnotationSet, str, PathLike, Any] = None,
    dims: collections.abc.Sequence[collections.abc.Sequence[str], None] = None,
    **kwargs ,
)-> ‘AnnotationSet’

Load annotations from whatever holds them.

The one door every source goes through, as dascore.spool is for patches: a set comes back from a set, a directory, a table on disk, or anything a dataframe can be built from.

Parameters

Parameter Description
source An AnnotationSet, a path to a set directory or a CSV table, or a
dataframe of one row per annotation.
dims The patch dimensions the annotations are stated in. Required unless
the source states them itself, and overriding it where it does.
**kwargs Passed to AnnotationSet.
A source already holding what one states – a set, or a directory
holding its own attributes and vertices – refuses it rather than
dropping it.

Examples

import pandas as pd
import dascore as dc
frame = pd.DataFrame({"group": ["event"], "distance": [10.0]})
picks = dc.annotations(frame, dims=("distance",))
len(picks)
dc.annotations(picks) is picks
True