ehrapy.anndata.anndata_to_df#
- ehrapy.anndata.anndata_to_df(adata, layer=None, obs_cols=None, var_cols=None)[source]#
Transform an AnnData object to a Pandas DataFrame.
- Parameters:
adata (
AnnData) – The AnnData object to be transformed into a pandas DataFramelayer (
str, default:None) – The layer to access the values of. If not specified, it uses the X matrix.obs_cols (
Iterable[str] |str|None, default:None) – The columns of obs to add to the DataFrame.var_cols (
Iterable[str] |str|None, default:None) – The columns of var to fetch values from.
- Return type:
- Returns:
The AnnData object as a pandas DataFrame
Examples
>>> import ehrapy as ep >>> adata = ep.dt.mimic_2(encoded=True) >>> df = ep.ad.anndata_to_df(adata)