colstore.TableView¶
- class colstore.TableView(store, row_part, column_names)[source]¶
Bases:
_ColumnTable,_BaseViewView of multiple columns produced by any non-string indexing.
Materializes through
array()(one column, by name),dict(),recarray(), orframe(). There is no no-argumentarray()– several columns generally have different dtypes and cannot be packed into a single homogeneous ndarray; read one column by name (view['col']/view.array('col')) or userecarray()for all of them. Indexing by a name projects a column (view['col']→ aColumnView) and by a list of names a sub-table (view[['a', 'b']], the same asselect()); a row selector (view[:100],view[idx],view[mask]) narrows the rows, composed onto the view’s selection, andview[rows, cols]does both.- __getitem__(key)[source]¶
Narrow this table by columns or rows.
view['col']/view[['a', 'b']]project columns (as before); a row selector –view[:100],view[idx],view[mask]– narrows the rows, composed onto the view’s current selection; andview[rows, cols]does both. Sods[:1000, cols][:10]equalsds[:10, cols].- Parameters:
key (Any)
- Return type:
- select(*columns)[source]¶
Narrow this view to the named
columns(in the given order), same rows.Unknown names raise
KeyError; a single name still yields a (one-column)TableView. The row selection – including a lazycol()/querypredicate – is preserved.
- dict(copy=True)[source]¶
Materialize as a dict mapping column name to 1D ndarray.
- Parameters:
copy (bool, optional) –
True(default): owning arrays.False: READ-ONLY zero-copy views backed by the store’s open memmaps, all-or-nothing – seeColumnView.array()for the exact support conditions and lifetime semantics.recarrayhas no zero-copy form (it repacks by construction);frameacceptscopyand forwards it here, soframe(copy=False)aliases the same views.- Returns:
dict[str, numpy.ndarray] – Arrays in selection order; each column’s stored dtype is preserved.
- Return type:
- recarray()[source]¶
Materialize as a structured (record) ndarray with one field per column.
- Returns:
numpy.ndarray – Structured 1D array.
result[name]returns the column.- Return type:
- frame(copy=True)[source]¶
Materialize as a pandas DataFrame.
- Parameters:
copy (bool, optional) –
True(default): owning columns.False: a READ-ONLY DataFrame whose columns are zero-copy views, forwarding the same conditions and lifetime asdict()(raising rather than copying when any column cannot be viewed).- Returns:
pandas.DataFrame – Columns are in selection order with their stored dtypes preserved.
- Return type:
pd.DataFrame
- evaluate()[source]¶
Resolve the (lazy) row selection now; return a view over the concrete rows.
For a
col()/queryselection this reads the predicate columns and computes the boolean row mask once, returning an equivalent view whose rows are already resolved – so a later.frame()/.dict()/.recarray()(or the head/preview helpers) does not recompute the selection. The selected columns are not materialized.- Return type: