annotation_set_to_csv

function of dascore.core.annotations source

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

Return the annotations as CSV text, optionally writing it to a path.

Reached as annotation_set.io.to_csv.

A bare table states one grain, so a set holding vertices is written with save instead; this is the spelling for a set of regions.

The dimensions are not written: they are not a column, and the only place a CSV has for them is a comment line, which a reader not told to expect one takes for the header. Reading such a table back states them again, in the call or in a # dims: distance, time line written above the header by hand.

Parameters

Parameter Description
annotations The set to write.
path Where to write the text, or None to only return it.

Examples

import pandas as pd
import dascore as dc
frame = pd.DataFrame(
    {"group": ["event"], "distance_start": [10.0], "distance_end": [80.0]}
)
annotations = dc.AnnotationSet(frame, dims=("time", "distance"))
"group" in annotations.io.to_csv()
True