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 table as one parquet file.

Reached as annotation_set.io.to_parquet.

The parquet spelling of to_csv: columns keep their types, and the dimensions travel in the file’s metadata. A column with no one type is written as JSON, which keeps each cell’s value but not every python type – a tuple comes back as a list. Needs pyarrow.

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(
    {"phase": ["P"], "distance_min": [10.0], "distance_max": [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