annotation_set_to_parquet

function of dascore.core.annotations source

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

Write the annotations as one parquet file.

Reached as annotation_set.io.to_parquet.

The parquet spelling of to_csv, for a set too big to want text. It keeps what a CSV cannot: a column parquet has a type for comes back as that type rather than as a spelling to be guessed at, and the dimensions travel in the file’s own metadata rather than having to be stated again. A column with no one type is written as JSON, which keeps the value of each cell but not every python type it may have been held in – a tuple comes back as a list.

Needs pyarrow, which CSV does not; a set of regions can always be written as a table, whatever is installed.

Parameters

Parameter Description
annotations The set to write.
path Where to write the file.

Returns

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

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"))
path = annotations.io.to_parquet("picks.parquet")  # doctest: +SKIP
dc.annotations(path) == annotations  # doctest: +SKIP
True