ehrdata.io.write_zarr

Contents

ehrdata.io.write_zarr#

ehrdata.io.write_zarr(edata, filename, *, chunks='auto', convert_strings_to_categoricals=True)#

Write EHRData objects to disk.

To write to a .zarr file, X, and layers cannot be written as object dtype. If any of these fields is of object dtype, it this function will attempt to cast it to a numeric dtype; if this fails, the field will be casted to a str dtype.

Parameters:
edata EHRData

Central data object.

filename str | Path

Name of the output file, can also be prefixed with relative or absolute path to save the file to.

chunks Literal[‘auto’ | ‘ehrdata_auto’] (default: 'auto')

Specify strategy of how data should be chunked. For simplicity, currently only 2 options are available: "auto" will write the data with write_elem()’s default settings. "ehrdata_auto" will write the data chunked (and sharded) based on a heuristic that loosely speaking writes slightly smaller chunks.

convert_strings_to_categoricals bool (default: True)

Convert columns of str dtype in .obs and .var and .tem to categorical dtype.

Return type:

None

Examples

>>> import ehrdata as ed
>>> edata = ed.dt.mimic_2()
>>> ed.io.write_zarr("mimic_2.zarr", edata)