anndata.acc.MetaAcc#

class anndata.acc.MetaAcc[R: AdRef[str | None, AnnDataLikeMetadataOnly]](dim, *, ref_class, scope=None, frame_acc=None)[source]#

Bases: DFAcc[R]

Reference accessor for arrays from metadata containers (A.obs/A.var).

Examples

You can refer to columns or the index in the way you would access them in a DataFrame:

>>> from anndata.acc import A, MetaAcc
>>> assert isinstance(A.obs, MetaAcc)
>>> A.obs["type"]
A.obs['type']
>>> A.var.index
A.var.index

Attributes

frame_acc: RefAcc | None = None#

Accessor for the data frame this .DF cast refers into, e.g. A.obsm['df'] for A.obsm['df'].DF.

property index: R[source]#

Index AdRef, e.g. A.obs.index or A.uns['df'].DF.index.

scope: ScopeAcc | None = None#

Accessor for the element whose .AD cast this accessor is in, e.g. A.uns['a'] for A.uns['a'].AD.obsm['x'].DF.

If None, this accessor refers into the object passed to get()/set()/isin() itself.

dim: Literal['obs', 'var']#

Axis this accessor refers to, e.g. A.obs.dim == 'obs'.

ref_class: type[R]#

Methods

dims(k, /)[source]#

Get along which dimensions the referenced array is.

Return type:

Collection[Literal['obs', 'var']]

frame(data, /)[source]#

Get the data frame this accessor refers to.

get(), set(), and isin() use this, so subclasses only need to override this to refer to another frame (e.g. MetaAcc returns .obs/.var of container()).

Raises:

TypeError – If the element frame_acc refers to isn’t a data frame.

Return type:

DataFrame | Dataset2D

set(data, k, value, /)[source]#

Set the indexed array or element in the AnnData object at idx.

When idx is NO_IDX, replace the full element one level up (see get()), otherwise assign into the existing element in-place.

Return type:

None