table::column
On this page
Typed column storage: one packed List per column plus an optional
validity bitmap. A column and a contiguous Array<T, 1> share one
buffer, so from_array and to_f64 copy nothing where they can.
Structs
ColumnSource
pub struct ColumnOne typed column. Nulls are tracked by a validity bitmap; the slot under a null holds a zero value. Columns share their buffers when copied: they are read-only once built.
let c = table::Column::from([1.5, 2.5, 4.0]);
assert(c.dtype() == table::DType::F64);
let a = try c.to_f64() catch _ { [0.0] };
assert(a.sum() == 8.0);
An
i64column.An
f64column. NaN is a value, not a null.A
boolcolumn.A
strcolumn.A
datecolumn.A
datetimecolumn.A categorical column: each distinct string stored once, a
u32code per row.nabilet c = table::Column::cat(["red", "blue", "red"]); assert(c.dtype() == table::DType::Cat); assert(c.levels() == ["red", "blue"]);The
f64arrayaas a column. A contiguous array shares its buffer with the column (no copy), so write toa.copy()instead ofaonce it is in a table; a strided view is copied.nabiuse core::array::Array; let a: Array<f64, 1> = [1.0, 2.0]; assert(table::Column::from_array(a).len() == 2);The
i64arrayaas a column, sharing its buffer asfrom_arraydoes.The
boolarrayaas a column, sharing its buffer asfrom_arraydoes.nnulls of typet.
Sourcepub fn from_values(§vs: List<Value>, t: DType | none) throws (TableError) -> Column Cells of one type,
Value::Nullfor a missing one. The type is the first non-null cell's;IntandFloatmixed givef64. All-null input givest(F64whentisnone).nabiuse table::Value; let c = try table::Column::from_values([Value::Int(1), Value::Null, Value::Float(2.5)], none) catch _ { table::Column::f64s([]) }; assert(c.dtype() == table::DType::F64 && c.null_count() == 1);The number of rows.
No rows.
The column type.
How many rows are null.
Whether row
iis null.Whether row
iholds a value.Row
ias a cell;Value::Nullfor a null oripast the end.The cells in order.
The distinct strings of a
Catcolumn, in code order; empty for other types.
Sourcepub fn to_f64(§self) throws (TableError) -> Array<f64, 1> The values of a numeric column as an
f64array;i64converts and nulls read as NaN. Anf64column without nulls shares its buffer with the array (no copy): treat it as read-only, since a write would change every table holding the column, and write toa.copy()instead.
Sourcepub fn f64_list(§self) throws (TableError) -> List<f64> As
to_f64, as a list.
Sourcepub fn to_i64(§self) throws (TableError) -> Array<i64, 1> The values of an
i64column as an array sharing the column's buffer (read-only, as forto_f64); nulls read as 0.
Sourcepub fn to_bool(§self) throws (TableError) -> Array<bool, 1> The values of a
boolcolumn as an array sharing the column's buffer (read-only, as forto_f64); nulls read asfalse.
Sourcepub fn to_strs(§self) throws (TableError) -> List<str> The strings of a
strorcatcolumn; nulls read as"".The column with every cell
nonewhere it is null.nabilet c = table::column![1, none, 3]; assert(c.to_options_i64() == [1, none, 3]);As
to_options_i64, for numbers asf64.As
to_options_i64, for text.Dictionary-encode a
strcolumn (others are returned as they are). Levels keep first-seen order.
Sourcepub fn cast(§self, t: DType) throws (TableError) -> Column The column as type
t. Numbers convert betweeni64andf64(f64toi64truncates toward zero; NaN and out-of-range values are an error), anything converts tostr, andstrparses into the other types (an unparseable cell is an error naming the row).nabilet c = table::Column::from(["1", "2", "x"]); assert((try c.cast(table::DType::I64) catch _ { c }).dtype() == table::DType::Str); let n = try table::Column::from(["1", "2"]).cast(table::DType::F64) catch _ { c }; assert(n.dtype() == table::DType::F64);Rows
start..end(clamped to the length), sharing the buffer.The rows at
idx, in that order (a gather).The rows where
maskistrue.
Sourcepub fn concat(§self, o: Column) throws (TableError) -> Column selftheno; both must have one type (i64withf64givesf64,catwithstrgivesstr).One flag per row,
truewhere it holds a value.
Trait implementations 15
impl From<List<i64>> for Columnimpl From<List<f64>> for Columnimpl From<List<bool>> for Columnimpl From<List<str>> for Columnimpl From<List<Date>> for Columnimpl From<List<DateTime>> for Columnimpl From<Array<f64, 1>> for Columnimpl From<Array<i64, 1>> for Columnimpl From<Array<bool, 1>> for Columnimpl From<List<i64 | none>> for Columnimpl From<List<f64 | none>> for Columnimpl From<List<bool | none>> for Columnimpl From<List<str | none>> for Columnimpl PartialEq for Columnimpl Debug for Column