nimare.studyset.ColumnStore
- class ColumnStore(n_rows: int, dense: dict = <factory>, sparse: dict = <factory>)[source]
Bases:
objectColumns 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
selas 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_rowsdensesparse- add_sparse(name, idx, values)[source]
Record a column present only on
idx.An empty
idxstill registers the column: a field declared everywhere but populated nowhere is still a declared field, and dropping it would change whatget_metadata()reports and lose it on export.
- 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.
- get_numeric(name, sel=None, fill=nan, reduce=<function mean>)[source]
Values for
selas float64, reducing list-valued entries.This is what blocks want: no
None, no object dtype, missing rows as NaN. The object-dtypeget()stays available for callers that need to tellNonefromnan.
- 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 reasonadd_sparse()records them.