colstore.ColumnView¶
- class colstore.ColumnView(store, row_part, column_name)[source]¶
Bases:
NDArrayOperatorsMixin,ColumnReductions,_BaseViewLazy view of a single column produced by indexing with a string name.
Materializes to a 1D
numpy.ndarrayviaarray(). No other materialization method is available; callingdict(),recarray(), orframe()here would not make sense and those methods are intentionally absent from this class.A column view is an eager read surface, so the elementwise operators and NumPy ufuncs it inherits compute immediately:
ds[name] * 2,ds['a'] + ds['b'],ds[name] > 0, andnp.log(ds[name])each gather the selected rows and return a plainndarray. To build a deferred transform that composes without reading, edit the store into a frame (reader.edit()); to select rows by a column predicate, usecol()/query().- Parameters:
store (_ReaderBase)
row_part (Any)
column_name (str)
- __getitem__(key)[source]¶
Narrow this column’s rows:
ds['x'][:100]reads the first 100x.Composes
key(a slice, integer, integer array, or boolean mask) onto the view’s current row selection, the same asds[<view rows>[key], 'x']– sods['x'][:100]equalsds[:100, 'x']. To read the values, callarray()(ornp.asarray).- Parameters:
key (Any)
- Return type:
- array(copy=True)[source]¶
Materialize as a 1D ndarray.
- Parameters:
copy (bool, optional) –
True(default): an owning array, safe to mutate and to use after the store is closed.False: a READ-ONLY zero-copy view backed by the store’s open memmap, supported exactly when the store is single-record, the column’s dtype is in native byte order, and the row selector isNone, an int, or a slice; anything else raisesValueErrorrather than silently copying. The view holds a reference to the mapping, so it stays valid after the store is closed – at the cost of keeping the file mapped until the view is garbage-collected.- Returns:
numpy.ndarray – 1D array of the selected rows in the column’s stored dtype.
- Return type:
- isin(values)[source]¶
Boolean mask of which selected rows’ values are in
values– eager (np.isin).Reads this column’s selected rows and tests membership, returning a plain boolean
ndarrayto use as a mask, e.g.ds[ds['id'].isin(keep)]. On a frame column (frame[name]) the same call is lazy instead (a boolean expression).
- 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.array()does not recompute the selection. The column itself is not materialized.- Return type: