write_parquet

function of dascore.utils.tables source

write_parquet(
    frame: DataFrame ,
    path ,
    metadata: collections.abc.Mapping | None[Mapping, None] = None,
)-> ‘None’

Write a dataframe as one parquet file, keeping the values it holds.

Parquet stores types, so a column comes back as what it was written as rather than as text a reader has to guess at. A column with no single type – one holding both text and booleans, or a model, or a nested mapping – has no parquet type of its own; each of its cells is written as a JSON document instead, and the file names those columns in its metadata so a reader gets the values back rather than their spelling.

Parameters

Parameter Description
frame The table to write.
path Where to write it.
metadata Key-value strings for the file’s own metadata, which
read_parquet hands back. A
format states here what its table cannot say in a column.

Examples

import tempfile  # doctest: +SKIP
from pathlib import Path
import pandas as pd
from dascore.utils.tables import read_parquet, write_parquet
frame = pd.DataFrame({"group": ["rail"], "value": [True]})
with tempfile.TemporaryDirectory() as folder:  # doctest: +SKIP
    path = Path(folder) / "coupling.parquet"
    write_parquet(frame, path, {"dascore:dims": "distance"})
    out, stated = read_parquet(path)
out.equals(frame), stated["dascore:dims"]  # doctest: +SKIP
(True, 'distance')