save_annotation_set

function of dascore.core.annotations source

save_annotation_set(
    annotations: AnnotationSet ,
    path: str | pathlib._local.Path[str, Path] ,
    format: str = csv,
)-> ‘pathlib.Path’

Write the set to a directory, creating it if needed.

Reached as annotation_set.io.save. The directory holds attrs.json, the annotations table, a features table when the set has features, and bases.json when it has bases; it reads back through dascore.annotations. Tables are CSV by default or parquet when requested; duration dimensions require parquet. Saving replaces stale parts and alternate-format files.

Parameters

Parameter Description
annotations The set to write.
path The directory to write into.
format The encoding the tables are written in: csv or parquet.

Returns

The directory written to, so a save reads straight back.

Examples

import pandas as pd
import dascore as dc
frame = pd.DataFrame(
    {"phase": ["P"], "distance_min": [10.0], "distance_max": [80.0]}
)
annotations = dc.AnnotationSet(frame, dims=("time", "distance"))
directory = annotations.io.save("picks")  # doctest: +SKIP
dc.annotations(directory) == annotations  # doctest: +SKIP
True