nimare.studyset.ColumnStore

class ColumnStore(n_rows: int, dense: dict = <factory>, sparse: dict = <factory>)[source]

Bases: object

Columns aligned to one level’s row index, dense or sparse.

Methods

add_dense(name, values)

Record a column present on every row.

add_sparse(name, idx, values)

Record a column present only on idx.

copy()

Return a shallow copy sharing the underlying arrays.

entries(name)

Return (rows, values) for a column, whatever its density.

freeze()

Mark every dense column read-only and return self.

get(name[, sel, fill])

Values for sel (or every row) as an object array.

get_numeric(name[, sel, fill, reduce])

Values for sel as float64, reducing list-valued entries.

keys()

Every column name, dense and sparse.

reorder(order, inverse)

Permute in place: dense columns gather, sparse indices remap.

rows(wanted)

{row: {name: value}} for the requested rows, skipping nulls.

subset(keep)

Return a new store holding only keep, in the order given.

Properties

n_rows

dense

sparse

add_dense(name, values)[source]

Record a column present on every row.

add_sparse(name, idx, values)[source]

Record a column present only on idx.

An empty idx still registers the column: a field declared everywhere but populated nowhere is still a declared field, and dropping it would change what get_metadata() reports and lose it on export.

copy()[source]

Return a shallow copy sharing the underlying arrays.

entries(name)[source]

Return (rows, values) for a column, whatever its density.

A dense column is every row; a sparse one is the rows it was recorded for. Callers that only want “which rows have a value, and what is it” should not have to care which, and six of them used to.

freeze()[source]

Mark every dense column read-only and return self.

get(name, sel=None, fill=None)[source]

Values for sel (or every row) as an object array.

get_numeric(name, sel=None, fill=nan, reduce=<function mean>)[source]

Values for sel as float64, reducing list-valued entries.

This is what blocks want: no None, no object dtype, missing rows as NaN. The object-dtype get() stays available for callers that need to tell None from nan.

keys()[source]

Every column name, dense and sparse.

reorder(order, inverse)[source]

Permute in place: dense columns gather, sparse indices remap.

rows(wanted)[source]

{row: {name: value}} for the requested rows, skipping nulls.

subset(keep)[source]

Return a new store holding only keep, in the order given.

Unlike reorder() this changes the row count, so a sparse entry whose row is dropped has to go rather than be remapped. Declared-but- empty columns are preserved for the same reason add_sparse() records them.