Skip to main content

ClikaRT::tables::Table

class

Header: ClikaRT/tables/table.h

A columnar dataframe: an ordered set of named, typed columns sharing one row count (see the file overview for the model). Build with create() + add_column / read_csv, read columns back as tensors, iterate rows with rows(), transform with the verb methods, and mutate columns in place via frame[name].

Nested types

NameDescription
AggSpecOne aggregation of a group_by: the column, the reduction, and the output name.
ColumnRefThe handle returned by frame[name]. Compound ops mutate the live column (the scalar broadcasts); = tensor creates or replaces the column. On a failure (missing column, non-numeric, length mismatch) the op raises ClikaRT::Error in your translation unit, in BOTH library modes: a chaining operator returns *this and cannot carry a Result, so this block is the documented mode-invariant throwing surface. pow / floordiv are methods (C++ has no ** / //).
RowA lightweight read cursor over one row: just {table, row index}, no copy of the row's data. Typed getters WIDEN to the requested type: any integer (or Bool) column reads through get_int, any float column through get_double, a String column through get_string. Each raises ClikaRT::Error on a missing column, a null cell, or a column whose dtype the getter can't produce (e.g. get_int on a float column). Obtain a Row from rows() or row(i); the frame must outlive it.
RowRangeA range over every row, in order, range-for compatible: for (Table::Row row : frame.rows()) { ... }. Yields Row by value (the cheap cursor; no per-row allocation). The frame must outlive the range.
SortKeyOne key of a multi-key sort (most significant first), with its own direction and null placement.

Types

enum SortOrder

enum class SortOrder

Sort direction for sort_by.

EnumeratorDescription
Ascending
Descending

Declared in ClikaRT/tables/table.h, line 200

enum NullOrder

enum class NullOrder

Null placement for a multi-key sort.

EnumeratorDescription
First
Last

Declared in ClikaRT/tables/table.h, line 202

enum JoinKind

enum class JoinKind

Join flavor for join: Inner keeps matched rows only; Left / Right additionally keep that side's unmatched rows (nulls fill the other side); Outer keeps both sides' unmatched rows.

EnumeratorDescription
Inner
Left
Right
Outer

Declared in ClikaRT/tables/table.h, line 206

enum Agg

enum class Agg

Group-by aggregations, each over a group's non-null values: Count (the non-null count), Sum, Mean, Min, Max, Prod.

EnumeratorDescription
Count
Sum
Mean
Min
Max
Prod

Declared in ClikaRT/tables/table.h, line 209

Static member functions

create()

static Table create()

An empty frame; add columns with add_column / add_string_column.

Declared in ClikaRT/tables/table.h, line 56

read_csv()

static Table read_csv(std::string_view path, const CsvReadOptions& options = {})

Read an RFC-4180 CSV file / string into a frame (dtypes inferred). path / text is copied, not retained.

Declared in ClikaRT/tables/table.h, line 82

read_csv_string()

static Table read_csv_string(std::string_view text, const CsvReadOptions& options = {})

The string form of read_csv: parse text as CSV (dtypes inferred).

Throws

  • ClikaRT::Error: on malformed CSV.

Declared in ClikaRT/tables/table.h, line 85

Member functions

Table(Table)

Table(const Table& other)

Deep copy: the new frame owns independent columns.

Declared in ClikaRT/tables/table.h, line 59

operator=(Table)

Table& operator=(const Table& other)

Deep-copy assignment: this frame's columns are replaced by copies of other's.

Declared in ClikaRT/tables/table.h, line 61

Table(Table)

Table(Table&& other) noexcept

Move: takes other's columns; other is left empty.

Declared in ClikaRT/tables/table.h, line 63

operator=(Table)

Table& operator=(Table&& other) noexcept

Move assignment: takes other's columns.

Declared in ClikaRT/tables/table.h, line 65

~Table()

~Table()

Releases the frame's columns.

Declared in ClikaRT/tables/table.h, line 67

add_column()

void add_column(std::string_view name, const Tensor& values)

Append a numeric column from a 1-D CPU tensor (its data is copied in). The first column fixes the row count; later columns must match it. The dtype follows the tensor's. Errors on a non-1-D / non-numeric tensor, a duplicate name, or a length mismatch.

Declared in ClikaRT/tables/table.h, line 74

add_string_column()

void add_string_column(std::string_view name, ClikaRT::Span<const std::string_view> values)

Append a string column (one value per row; the strings are copied in).

Declared in ClikaRT/tables/table.h, line 76

write_csv()

void write_csv(std::string_view path) const

Write the frame as CSV to path, or render it to a string.

Declared in ClikaRT/tables/table.h, line 87

to_csv_string()

std::string to_csv_string() const

Render the frame as CSV text, the write half of the round trip: a frame rendered here reads back with read_csv_string (dtypes re-inferred).

Throws

  • ClikaRT::Error: when rendering fails.

Declared in ClikaRT/tables/table.h, line 91

num_rows()

std::int64_t num_rows() const

Number of rows (0 for an empty frame).

Declared in ClikaRT/tables/table.h, line 95

num_columns()

std::int64_t num_columns() const

Number of columns.

Declared in ClikaRT/tables/table.h, line 97

column_names()

std::vector<std::string> column_names() const

The column names, in column order.

Declared in ClikaRT/tables/table.h, line 99

contains()

bool contains(std::string_view name) const

True when a column named name exists.

Declared in ClikaRT/tables/table.h, line 101

column()

Tensor column(std::string_view name) const

Materialize a numeric column as a 1-D owning tensor (a copy, safe to keep past the table's lifetime). Errors on a missing or non-numeric column.

Declared in ClikaRT/tables/table.h, line 106

null_count()

std::int64_t null_count(std::string_view name) const

Per-column null inspection. Nulls arise from a CSV empty field / a null_tokens match, or a null-producing op. Errors on a missing column.

Declared in ClikaRT/tables/table.h, line 110

has_nulls()

bool has_nulls(std::string_view name) const

True when the column carries at least one null.

Throws

  • ClikaRT::Error: on a missing column (as null_count).

Declared in ClikaRT/tables/table.h, line 113

to_string()

std::string to_string() const

Render the frame pandas-style (a large frame elides to its head + tail).

Declared in ClikaRT/tables/table.h, line 116

rows()

RowRange rows() const

Every row as a range, for for (Table::Row row : frame.rows()).

Declared in ClikaRT/tables/table.h, line 190

row()

Row row(std::int64_t i) const

The row at i (0-based). Raises ClikaRT::Error if i is out of range.

Declared in ClikaRT/tables/table.h, line 192

select()

Table select(ClikaRT::Span<const std::string_view> names) const

Keep only names, in that order (a projection).

Declared in ClikaRT/tables/table.h, line 225

Table head(std::int64_t n = 5) const

The first / last n rows.

Declared in ClikaRT/tables/table.h, line 227

tail()

Table tail(std::int64_t n = 5) const

The last n rows (default 5), head's tail-end sibling.

Throws

  • ClikaRT::Error: as head.

Declared in ClikaRT/tables/table.h, line 230

slice()

Table slice(std::int64_t offset, std::int64_t count) const

count rows starting at offset.

Declared in ClikaRT/tables/table.h, line 232

sort_by(string_view, SortOrder)

Table sort_by(std::string_view column, SortOrder order = SortOrder::Ascending) const

Stable sort by one column.

Declared in ClikaRT/tables/table.h, line 234

sort_by(Span< SortKey>)

Table sort_by(ClikaRT::Span<const SortKey> keys) const

Stable multi-key sort (keys most-significant-first; per-key direction + null placement).

Declared in ClikaRT/tables/table.h, line 237

unique()

Table unique(std::string_view column) const

Distinct values of a column (first-seen order), as a 1-column frame.

Declared in ClikaRT/tables/table.h, line 239

value_counts()

Table value_counts(std::string_view column) const

Frequency of each distinct non-null value, as a value+count frame sorted by count descending.

Declared in ClikaRT/tables/table.h, line 242

filter()

Table filter(const Tensor& mask) const

Keep the rows where the Bool mask (one element per row) is true.

Declared in ClikaRT/tables/table.h, line 244

group_by()

Table group_by(
    ClikaRT::Span<const std::string_view> keys,
    ClikaRT::Span<const AggSpec> aggs
) const

Group by keys and apply aggs, one row per group: the key columns then one column per aggregation.

Declared in ClikaRT/tables/table.h, line 247

join()

Table join(
    const Table& other,
    ClikaRT::Span<const std::string_view> on,
    JoinKind kind = JoinKind::Inner
) const

Equi-join with other on the on columns (present in both, same dtype).

Declared in ClikaRT/tables/table.h, line 250

operator[]()

ColumnRef operator[](std::string_view name)

Declared in ClikaRT/tables/table.h, line 318