cellarr_frame package

Submodules

cellarr_frame.base module

class cellarr_frame.base.CellArrayBaseFrame(uri=None, tiledb_array_obj=None, mode=None, config_or_context=None, validate=True)[source]

Bases: ABC

Abstract base class for TileDB DataFrame operations.

__abstractmethods__ = frozenset({'_read_query', '_read_slice', 'write_batch'})
__getitem__(key)[source]

Route slicing/querying to implementation.

Note that strings passed with square bracket notation e.g. A[“cell001”] are assumed to be queries. If you want to select a row using string indices, use a list of strings e.g. A[[“cell001”]].

Parameters:

key (Union[slice, str, Tuple[Any, ...]]) –

  • str: Query condition (e.g., “age > 20”)

  • slice/int: Row selection

  • tuple: (rows, columns) selection

Return type:

DataFrame

__init__(uri=None, tiledb_array_obj=None, mode=None, config_or_context=None, validate=True)[source]

Initialize the object.

Parameters:
  • uri (Optional[str]) – URI to the array. Required if ‘tiledb_array_obj’ is not provided.

  • tiledb_array_obj (Optional[Array]) – Optional, an already opened tiledb object.

  • mode (Optional[Literal['r', 'w', 'd', 'm']]) – Open mode (‘r’, ‘w’, ‘d’, ‘m’). Defaults to None (auto).

  • config_or_context (Union[Config, Ctx, None]) – TileDB Config or Ctx.

  • validate (bool) – Whether to validate the connection.

property column_names: List[str]

Get attribute/column names of the dataframe.

consolidate()[source]
Return type:

None

property index: DataFrame

Get index of the dataframe.

property index_names: List[str]

Get dimension/index names of the dataframe.

property mode: str | None

Get current array mode. If an external array is used, this is its open mode.

open_array(mode=None)[source]

Context manager for array operations.

rownames()[source]

Alias to index().

Return type:

DataFrame

property shape: Tuple[int, ...]

Get the shape of the dataframe (rows, columns).

vacuum()[source]
Return type:

None

abstractmethod write_batch(data, **kwargs)[source]

Write or append data to the frame.

Return type:

None

cellarr_frame.frame module

class cellarr_frame.frame.CellArrayFrame(uri=None, tiledb_array_obj=None, mode=None, config_or_context=None, validate=True)[source]

Bases: CellArrayBaseFrame

Implementation for TileDB DataFrames.

__abstractmethods__ = frozenset({})
__annotations__ = {}
classmethod create(uri, data, index_dims=None, full_domain=True, **kwargs)[source]

Helper to create a new CellFrame from a dataframe.

Parameters:
  • uri (str) – Path to create array.

  • data (DataFrame) – Initial dataframe (can be empty schema if used with mode=’schema_only’).

  • index_dims (Optional[List[str]]) – Columns to use as dimensions (indices).

  • full_domain (bool) – Whether to allow the domain to extend to the full range of the dtype (default True).

write_batch(data, append=True, **kwargs)[source]

Write a batch of data to the frame.

Parameters:
  • data (DataFrame) – Pandas DataFrame to write.

  • append (bool) – If True, appends to existing array. If False, might overwrite/schema_only depending on lower-level tiledb.from_pandas behavior, but mostly used for appending.

Return type:

None

Module contents