ehrapy.anndata.move_to_x

Contents

ehrapy.anndata.move_to_x#

ehrapy.anndata.move_to_x(edata, to_x, copy_x=False)[source]#

Move features from obs to X inplace.

Parameters:
  • edata (EHRData | AnnData) – Central data object

  • to_x (list[str] | str) – The columns to move to X

  • copy_x (bool, default: False) – The values are copied to X (and therefore kept in obs) instead of moved completely

Return type:

EHRData | AnnData

Returns:

A new data object with moved columns from obs to X. This should not be used for datetime columns currently.

Examples

>>> import ehrdata as ed
>>> import ehrapy as ep
>>> edata = ed.dt.mimic_2()
>>> ep.ad.move_to_obs(edata, ["age"], copy_obs=False)
>>> new_edata = ep.ad.move_to_x(edata, ["age"])