colstore.ColumnView

class colstore.ColumnView(store, row_part, column_name)[source]

Bases: NDArrayOperatorsMixin, ColumnReductions, _BaseView

Lazy view of a single column produced by indexing with a string name.

Materializes to a 1D numpy.ndarray via array(). No other materialization method is available; calling dict(), recarray(), or frame() 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, and np.log(ds[name]) each gather the selected rows and return a plain ndarray. To build a deferred transform that composes without reading, edit the store into a frame (reader.edit()); to select rows by a column predicate, use col() / query().

Parameters:
  • store (_ReaderBase)

  • row_part (Any)

  • column_name (str)

__getitem__(key)[source]

Narrow this column’s rows: ds['x'][:100] reads the first 100 x.

Composes key (a slice, integer, integer array, or boolean mask) onto the view’s current row selection, the same as ds[<view rows>[key], 'x'] – so ds['x'][:100] equals ds[:100, 'x']. To read the values, call array() (or np.asarray).

Parameters:

key (Any)

Return type:

ColumnView

property column: str

Name of the column selected by this view.

property dtype: dtype

NumPy dtype of the selected column.

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 is None, an int, or a slice; anything else raises ValueError rather 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:

ndarray

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 ndarray to 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).

Parameters:

values (Any)

Return type:

ndarray

evaluate()[source]

Resolve the (lazy) row selection now; return a view over the concrete rows.

For a col() / query selection 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:

ColumnView

head(n=None)[source]

First n values of the column as a previewable peek (default config rows).

Parameters:

n (int | None)

Return type:

Preview

tail(n=None)[source]

Last n values of the selected column, as a previewable peek.

Parameters:

n (int | None)

Return type:

Preview