ehrdata.io.write_h5ed

Contents

ehrdata.io.write_h5ed#

ehrdata.io.write_h5ed(edata, filename, *, compression=None, compression_opts=None)#

Write EHRData objects to an ehrdata hdf5 file (.h5ed).

.h5ed is the ehrdata on-disk format. To write the file, X and layers cannot be written as object dtype. If any of these fields is of object dtype, this function will attempt to cast it to a numeric dtype; if this fails, the field will be casted to a string 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.

compression Literal['gzip', 'lzf'] | None (default: None)

Optional file compression. Setting compression to ‘gzip’ can save disk space but will slow down writing and subsequent reading.

compression_opts int | None (default: None)

For [lzf, gzip], see the h5py Filter pipeline.

Return type:

None

Examples

>>> import ehrdata as ed
>>> edata = ed.dt.mimic_2()
>>> ed.io.write_h5ed(edata, "mimic_2.h5ed")