ehrapy.anndata.move_to_obs

Contents

ehrapy.anndata.move_to_obs#

ehrapy.anndata.move_to_obs(edata, to_obs, copy_obs=False)[source]#

Move inplace or copy features from X to obs.

Note that columns containing boolean values (either 0/1 or True(true)/False(false)) will be stored as boolean columns whereas the other non-numerical columns will be stored as categorical.

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

  • to_obs (list[str] | str) – The columns to move to obs.

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

Return type:

EHRData | AnnData

Returns:

The original data object with moved or copied columns from X to obs

Examples

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