ehrdata.io.write_h5ad#
- ehrdata.io.write_h5ad(edata, filename, *, compression=None, compression_opts=None)#
Write
EHRDataobjects to an hdf5 file.It is possible to either write an
EHRDataobject to an.h5ador a compressed.gziporlzffile. To write to an h5ad file,Xandlayerscannot be written asobjectdtype. If any of these fields is ofobjectdtype, it this function will attempt to cast it to a numeric dtype; if this fails, the field will be casted to a string dtype.- Parameters:
- filename
str|Path Name of the output file, can also be prefixed with relative or absolute path to save the file to.
- edata
EHRData Central data object.
- 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)
- filename
- Return type:
Examples
>>> import ehrdata as ed >>> edata = ed.dt.mimic_2() >>> ed.io.write_h5ad("mimic_2.h5ad", edata)