Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Introduction to dataframes

The dataframes package provides pandas-like tabular data for Maxima. It extends the numerics ndarray ecosystem with string columns and mixed-type tables, enabling work with real-world datasets that combine numeric and categorical data.

Requirements: SBCL (Steel Bank Common Lisp). The numerics package is loaded automatically.

Key concepts

string-column is a 1D column of strings, the text counterpart to ndarray. It uses 1-based indexing (matching Maxima convention) and appears as an opaque handle, like ndarray.

df_table is a columnar table with named, typed columns. Each column is either an ndarray (for numeric data) or a string-column (for text data). Tables are the primary container for mixed-type tabular data.

Quick start

(%i1) load("dataframes")$
(%i2) names : df_string_column(["Alice", "Bob", "Charlie"]);
(%o2)      string_column(3) ["Alice", "Bob", "Charlie"]
(%i3) scores : ndarray([95.0, 87.0, 92.0])$
(%i4) T : df_table(["name", "score"], [names, scores]);
(%o4)              df_table: 3 rows x 2 cols
(%i5) df_table_column(T, "name");
(%o5)      string_column(3) ["Alice", "Bob", "Charlie"]
(%i6) df_table_column(T, "score");
(%o6)            ndarray([3], DOUBLE-FLOAT)

String columns

(%i1) sc : df_string_column(["red", "green", "blue"]);
(%o1)       string_column(3) ["red", "green", "blue"]
(%i2) df_string_column_ref(sc, 1);
(%o2)                          red
(%i3) df_string_column_length(sc);
(%o3)                          3
(%i4) df_to_string_list(sc);
(%o4)                [red, green, blue]

Mixed tables

(%i1) regions : df_string_column(["North", "South", "East", "West"])$
(%i2) revenue : ndarray([100.0, 150.0, 120.0, 180.0])$
(%i3) T : df_table(["region", "revenue"], [regions, revenue])$
(%i4) df_table_shape(T);
(%o4)                        [4, 2]
(%i5) df_table_names(T);
(%o5)                [region, revenue]
(%i6) T2 : df_table_head(T, 2)$
(%i7) df_table_shape(T2);
(%o7)                        [2, 2]

Converting between tables and ndarrays

(%i1) A : np_eye(3)$
(%i2) T : df_ndarray_to_table(A, ["a", "b", "c"])$
(%i3) df_table_shape(T);
(%o3)                        [3, 3]
(%i4) B : df_table_to_ndarray(T)$
(%i5) np_shape(B);
(%o5)                        [3, 3]

Definitions for dataframes

String Columns

A string-column is an opaque handle wrapping a 1D column of strings. It is the string counterpart to ndarray, designed for categorical labels, names, and other non-numeric data.

String-columns use 1-based indexing (matching Maxima convention).


df_string_column (list) — Function

Create a string-column from a Maxima list of strings.

Each element is converted to a string via sconcat.

Examples

(%i1) sc : df_string_column(["Alice", "Bob", "Charlie"]);
(%o1)      string_column(3) ["Alice", "Bob", "Charlie"]
(%i2) df_string_column_length(sc);
(%o2)                          3
(%i3) df_string_column_ref(sc, 1);
(%o3)                        Alice

See also: df_to_string_list, df_string_column_p


df_to_string_list (col) — Function

Convert a string-column back to a Maxima list of strings.

Examples

(%i1) sc : df_string_column(["x", "y", "z"]);
(%o1)          string_column(3) ["x", "y", "z"]
(%i2) df_to_string_list(sc);
(%o2)                      [x, y, z]

See also: df_string_column


df_string_column_p (x) — Function

Predicate: return true if x is a string-column handle, false otherwise.

Examples

(%i1) df_string_column_p(df_string_column(["a", "b"]));
(%o1)                         true
(%i2) df_string_column_p(42);
(%o2)                        false
(%i3) df_string_column_p(ndarray([1, 2, 3]));
(%o3)                        false

See also: df_string_column


df_string_column_ref (col, i) — Function

Access element i (1-indexed) of a string-column.

Signals an error if i is out of bounds.

Examples

(%i1) sc : df_string_column(["red", "green", "blue"]);
(%o1)       string_column(3) ["red", "green", "blue"]
(%i2) df_string_column_ref(sc, 1);
(%o2)                          red
(%i3) df_string_column_ref(sc, 3);
(%o3)                         blue

See also: df_string_column_length, df_to_string_list


df_string_column_length (col) — Function

Return the number of elements in a string-column.

Examples

(%i1) df_string_column_length(df_string_column(["a", "b", "c"]));
(%o1)                          3
(%i2) df_string_column_length(df_string_column([]));
(%o2)                          0

See also: df_string_column_ref, df_table_shape

Tables

A df_table is a columnar table with named, typed columns. Each column is either an ndarray (numeric data) or a string-column (text data). All columns must have the same number of rows.


df_table (names, columns) — Function

Create a table from a list of column names and a list of columns.

Each column can be an ndarray or a string-column. The names argument is a Maxima list of strings. The columns argument is a Maxima list of column handles.

Examples

/* Numeric-only table */
(%i1) x : ndarray([1.0, 2.0, 3.0])$
(%i2) y : ndarray([4.0, 5.0, 6.0])$
(%i3) T : df_table(["x", "y"], [x, y]);
(%o3)              df_table: 3 rows x 2 cols

/* Mixed table with strings and numbers */
(%i4) names : df_string_column(["Alice", "Bob", "Charlie"])$
(%i5) scores : ndarray([95.0, 87.0, 92.0])$
(%i6) T2 : df_table(["name", "score"], [names, scores]);
(%o6)              df_table: 3 rows x 2 cols

See also: df_table_column, df_table_shape, df_table_names


df_table_column (T, name) — Function

Extract a column by name from a table.

Returns an ndarray for numeric columns or a string-column for text columns. Signals an error if the column name is not found.

Examples

(%i1) names : df_string_column(["x", "y", "z"])$
(%i2) vals : ndarray([1.0, 2.0, 3.0])$
(%i3) T : df_table(["name", "value"], [names, vals])$
(%i4) df_table_column(T, "name");
(%o4)          string_column(3) ["x", "y", "z"]
(%i5) ndarray_p(df_table_column(T, "value"));
(%o5)                         true
(%i6) df_string_column_p(df_table_column(T, "name"));
(%o6)                         true

See also: df_table, df_table_names


df_table_shape (T) — Function

Return the shape of a table as [nrows, ncols].

Examples

(%i1) x : ndarray([1.0, 2.0, 3.0])$
(%i2) y : ndarray([4.0, 5.0, 6.0])$
(%i3) T : df_table(["x", "y"], [x, y])$
(%i4) df_table_shape(T);
(%o4)                        [3, 2]

See also: df_table_names, df_table


df_table_names (T) — Function

Return the column names of a table as a Maxima list of strings.

Examples

(%i1) x : ndarray([1.0, 2.0, 3.0])$
(%i2) y : ndarray([4.0, 5.0, 6.0])$
(%i3) T : df_table(["x", "y"], [x, y])$
(%i4) df_table_names(T);
(%o4)                        [x, y]

See also: df_table_shape, df_table_column


df_table_head (T) / df_table_head (T, n) — Function

Return the first n rows of a table as a new table.

Defaults to 5 rows if n is not given. Works with both numeric and string columns.

Examples

(%i1) names : df_string_column(["a", "b", "c", "d", "e"])$
(%i2) vals : ndarray([1.0, 2.0, 3.0, 4.0, 5.0])$
(%i3) T : df_table(["name", "value"], [names, vals])$
(%i4) T2 : df_table_head(T, 2)$
(%i5) df_table_shape(T2);
(%o5)                        [2, 2]
(%i6) df_to_string_list(df_table_column(T2, "name"));
(%o6)                        [a, b]

See also: df_table, df_table_shape


df_table_to_ndarray (T) — Function

Stack all numeric columns of a table into a 2D ndarray.

String columns are skipped. Signals an error if the table has no numeric columns. The result has shape [nrows, num_numeric_cols].

Examples

(%i1) x : ndarray([1.0, 2.0])$
(%i2) y : ndarray([3.0, 4.0])$
(%i3) T : df_table(["x", "y"], [x, y])$
(%i4) A : df_table_to_ndarray(T)$
(%i5) np_shape(A);
(%o5)                        [2, 2]
(%i6) np_to_matrix(A);
(%o6)          matrix([1.0, 3.0], [2.0, 4.0])

See also: df_ndarray_to_table, df_table


df_ndarray_to_table (A, names) — Function

Split a 2D ndarray into named columns, creating a table.

The names argument is a Maxima list of strings, one per column. The number of names must match the number of columns in the ndarray.

Examples

(%i1) A : np_eye(3)$
(%i2) T : df_ndarray_to_table(A, ["a", "b", "c"])$
(%i3) df_table_shape(T);
(%o3)                        [3, 3]
(%i4) df_table_names(T);
(%o4)                      [a, b, c]
(%i5) np_to_list(df_table_column(T, "a"));
(%o5)                  [1.0, 0.0, 0.0]

See also: df_table_to_ndarray, df_table


df_table_p (x) — Function

Predicate: return true if x is a table handle, false otherwise.

Examples

(%i1) x : ndarray([1.0, 2.0])$
(%i2) T : df_table(["x"], [x])$
(%i3) df_table_p(T);
(%o3)                         true
(%i4) df_table_p(42);
(%o4)                        false

See also: df_table, df_string_column_p

Column Aggregation and Describe

Column-level aggregation functions and df_describe for summary statistics. These functions work on individual columns (ndarray or string-column) and return scalars or new structures.


df_count (col) — Function

Count the number of elements in a column. Works on both ndarray and string-column.

Examples

(%i1) df_count(ndarray([1.0, 2.0, 3.0]));
(%o1)                          3
(%i2) df_count(df_string_column(["a", "b"]));
(%o2)                          2

See also: df_nunique, df_describe


df_median (col) — Function

Median of a 1D ndarray. For even-length arrays, returns the average of the two middle values.

Examples

(%i1) df_median(ndarray([3.0, 1.0, 2.0]));
(%o1)                         2.0
(%i2) df_median(ndarray([4.0, 1.0, 3.0, 2.0]));
(%o2)                         2.5

See also: df_quantile, df_describe


df_quantile (col, p) — Function

Compute the p-quantile (0 to 1) of a 1D ndarray using linear interpolation (NumPy default method).

Examples

(%i1) a : ndarray([3.0, 1.0, 4.0, 1.0, 5.0, 9.0, 2.0, 6.0])$
(%i2) df_quantile(a, 0.25);
(%o2)                         1.75
(%i3) df_quantile(a, 0.5);
(%o3)                         3.5
(%i4) df_quantile(a, 0.75);
(%o4)                         5.25

See also: df_median, df_describe


df_unique (col) — Function

Return a new string-column with the unique values from a string-column, preserving first-occurrence order.

Examples

(%i1) sc : df_string_column(["a", "b", "a", "c", "b"])$
(%i2) df_to_string_list(df_unique(sc));
(%o2)                      [a, b, c]

See also: df_nunique, df_value_counts


df_nunique (col) — Function

Count of unique values in a column. Works on both ndarray and string-column.

Examples

(%i1) df_nunique(df_string_column(["a", "b", "a", "c"]));
(%o1)                          3
(%i2) df_nunique(ndarray([1.0, 2.0, 1.0, 3.0]));
(%o2)                          3

See also: df_unique, df_value_counts


df_value_counts (col) — Function

Frequency table for a column, returned as a df_table with columns "value" and "count", sorted by count descending. Works on string-columns and ndarrays.

Examples

(%i1) sc : df_string_column(["a", "b", "a", "c", "b", "a"])$
(%i2) vc : df_value_counts(sc)$
(%i3) df_table_names(vc);
(%o3)                    [value, count]
(%i4) df_to_string_list(df_table_column(vc, "value"));
(%o4)                      [a, b, c]
(%i5) np_to_list(df_table_column(vc, "count"));
(%o5)                  [3.0, 2.0, 1.0]

See also: df_nunique, df_unique


df_describe (T) — Function

Summary statistics for the numeric columns of a table. Returns a new df_table with a "stat" string-column labeling each row and one ndarray column per numeric input column. String columns are skipped.

The statistics computed are: count, mean, std (sample, n-1 denominator), min, 25%, 50% (median), 75%, max.

Examples

(%i1) prices : ndarray([10.0, 20.0, 30.0, 40.0, 50.0])$
(%i2) names : df_string_column(["A", "B", "C", "D", "E"])$
(%i3) T : df_table(["name", "price"], [names, prices])$
(%i4) df_describe(T);
(%o4)              df_table: 8 rows x 2 cols
(%i5) df_table_names(df_describe(T));
(%o5)                    [stat, price]

See also: df_median, df_quantile, df_count

Table Manipulation

dplyr-style verbs for filtering, selecting, sorting, transforming, and summarizing tables. Functions that accept predicates use Maxima lambda expressions where parameter names are automatically matched to column names.


df_filter (T, pred) — Function

Subset rows where pred returns true. The lambda’s parameter names are matched to table column names.

Examples

(%i1) T : df_table(["name", "price"],
                    [df_string_column(["A","B","C"]), ndarray([10.0, 30.0, 20.0])])$
(%i2) df_filter(T, lambda([price], is(price > 15)));
(%o2)              df_table: 2 rows x 2 cols
(%i3) df_filter(T, lambda([name, price], is(price > 15) and name # "C"));
(%o3)              df_table: 1 rows x 2 cols

See also: df_select, df_slice


df_select (T, names) — Function

Subset and/or reorder columns by name.

Examples

(%i1) df_select(T, ["price"]);
(%o1)              df_table: 3 rows x 1 cols
(%i2) df_table_names(df_select(T, ["price", "name"]));
(%o2)                   [price, name]

See also: df_filter, df_rename


df_arrange (T, col_name) / df_arrange (T, col_name, descending) — Function

Sort rows by a column. Ascending by default; pass descending for reverse order. Works with both numeric and string columns.

Examples

(%i1) T2 : df_arrange(T, "price")$
(%i2) np_to_list(df_table_column(T2, "price"));
(%o2)                  [10.0, 20.0, 30.0]
(%i3) df_arrange(T, "price", descending)$

See also: df_filter, df_select


df_slice (T, indices) — Function

Subset rows by position (1-indexed).

Examples

(%i1) T2 : df_slice(T, [1, 3])$
(%i2) df_table_shape(T2);
(%o2)                        [2, 2]

See also: df_filter, df_table_head


df_rename (T, old_name, new_name) — Function

Rename a column.

Examples

(%i1) T2 : df_rename(T, "price", "cost")$
(%i2) df_table_names(T2);
(%o2)                     [name, cost]

See also: df_select


df_mutate (T, col_name, pred) — Function

Add or replace a column by applying a lambda row-wise. Lambda parameter names are matched to column names. If the column name already exists, it is replaced.

Examples

(%i1) T2 : df_mutate(T, "double", lambda([price], 2 * price))$
(%i2) df_table_names(T2);
(%o2)              [name, price, double]
(%i3) np_to_list(df_table_column(T2, "double"));
(%o3)                  [20.0, 60.0, 40.0]

See also: df_filter, df_summarize


df_summarize (T, name1, fn1, name2, fn2, …) — Function

Reduce a table to a single-row summary. Takes alternating name/lambda pairs. Each lambda receives whole columns (as ndarray or string-column handles) and must return a scalar.

Also works with grouped tables from df_group_by, producing one row per group.

Examples

(%i1) df_summarize(T, "avg", lambda([price], np_mean(price)),
                      "n",   lambda([price], df_count(price)));
(%o1)              df_table: 1 rows x 2 cols

See also: df_mutate, df_group_by, df_describe


df_distinct (T) / df_distinct (T, cols) — Function

Return unique rows. Optionally specify which columns to consider for uniqueness.

Examples

(%i1) T : df_table(["x"], [df_string_column(["a","b","a","c"])])$
(%i2) df_table_shape(df_distinct(T));
(%o2)                        [3, 1]

See also: df_filter, df_nunique

Grouped Tables

Group a table by a column for per-group aggregation with df_summarize.


df_group_by (T, col_name) — Function

Group a table by a column, returning a grouped table. The grouped table can then be passed to df_summarize to compute per-group statistics.

Examples

(%i1) T : df_table(["region", "revenue"],
                    [df_string_column(["N","S","N","S"]),
                     ndarray([10.0, 20.0, 30.0, 40.0])])$
(%i2) G : df_group_by(T, "region")$
(%i3) df_summarize(G, "total", lambda([revenue], np_sum(revenue)));
(%o3)              df_table: 2 rows x 2 cols

The result table has the group-key column plus one column per summary function.

See also: df_summarize, df_describe, df_grouped_table_p


df_grouped_table_p (x) — Function

Predicate: return true if x is a grouped table handle, false otherwise.

Examples

(%i1) T : df_table(["region", "revenue"],
                    [df_string_column(["N","S"]), ndarray([10.0, 20.0])])$
(%i2) G : df_group_by(T, "region")$
(%i3) df_grouped_table_p(G);
(%o3)                         true
(%i4) df_grouped_table_p(T);
(%o4)                        false

See also: df_group_by, df_table_p

Joins and Binds

Combine tables by key columns (joins) or by stacking (binds).


df_inner_join (T1, T2, key) — Function

Join two tables on a key column, keeping only rows with matching keys in both tables.

Examples

(%i1) T1 : df_table(["id", "name"],
                     [df_string_column(["1","2","3"]),
                      df_string_column(["Alice","Bob","Charlie"])])$
(%i2) T2 : df_table(["id", "score"],
                     [df_string_column(["1","2"]),
                      ndarray([90.0, 80.0])])$
(%i3) df_inner_join(T1, T2, "id");
(%o3)              df_table: 2 rows x 3 cols

See also: df_left_join, df_bind_cols


df_left_join (T1, T2, key) — Function

Join two tables on a key column, keeping all rows from the left table. Unmatched right columns are filled with 0 (numeric) or “” (string).

Examples

(%i1) df_left_join(T1, T2, "id");
(%o1)              df_table: 3 rows x 3 cols

See also: df_inner_join


df_bind_rows (T1, T2) — Function

Stack two tables vertically. Column names must match exactly.

Examples

(%i1) A : df_table(["x"], [ndarray([1.0, 2.0])])$
(%i2) B : df_table(["x"], [ndarray([3.0, 4.0])])$
(%i3) df_table_shape(df_bind_rows(A, B));
(%o3)                        [4, 1]

See also: df_bind_cols


df_bind_cols (T1, T2) — Function

Stack two tables horizontally. Row counts must match and column names must not overlap.

Examples

(%i1) X : df_table(["x"], [ndarray([1.0, 2.0])])$
(%i2) Y : df_table(["y"], [ndarray([3.0, 4.0])])$
(%i3) df_table_names(df_bind_cols(X, Y));
(%o3)                        [x, y]

See also: df_bind_rows, df_inner_join

DuckDB Integration

The dataframes-duckdb extension adds file I/O, SQL queries, and DuckDB-accelerated operations to the dataframes package. It requires libduckdb (brew install duckdb on macOS).

load("dataframes-duckdb")$

Type mapping: DuckDB DOUBLE → ndarray (f64), INTEGER/BIGINT → ndarray (coerced to f64), VARCHAR → string-column, NULL → NaN (numeric) or “” (string).


df_read_csv (path) — Function

Read a CSV file into a df_table. DuckDB auto-detects column types, delimiters, and encoding.

Examples

(%i1) T : df_read_csv("/path/to/data.csv")$
(%i2) df_table_shape(T);
(%o2)                        [100, 5]
(%i3) df_table_names(T);
(%o3)           [id, name, price, qty, region]

See also: df_read_parquet, df_read_json, df_write_csv


df_read_parquet (path) — Function

Read a Parquet file into a df_table.

Examples

(%i1) T : df_read_parquet("/path/to/data.parquet")$
(%i2) df_table_shape(T);
(%o2)                        [1000, 4]

See also: df_read_csv, df_write_parquet


df_read_json (path) — Function

Read a JSON file into a df_table. DuckDB auto-detects the JSON structure.

Examples

(%i1) T : df_read_json("/path/to/data.json")$
(%i2) df_table_shape(T);
(%o2)                        [50, 3]

See also: df_read_csv, df_read_parquet


df_write_csv (T, path) — Function

Write a df_table to a CSV file with header row.

Examples

(%i1) T : df_table(["name", "score"],
                    [df_string_column(["Alice", "Bob"]), ndarray([95.0, 87.0])])$
(%i2) df_write_csv(T, "/tmp/output.csv");
(%o2)                         done

See also: df_read_csv, df_write_parquet


df_write_parquet (T, path) — Function

Write a df_table to a Parquet file.

Examples

(%i1) df_write_parquet(T, "/tmp/output.parquet");
(%o1)                         done

See also: df_read_parquet, df_write_csv


df_sql (query) — Function

Execute an SQL query via DuckDB and return the result as a df_table. DuckDB can read files directly in SQL. Registered tables (via df_register) are available by name.

Examples

(%i1) T : df_sql("SELECT * FROM read_csv('data.csv') WHERE price > 10")$
(%i2) df_table_shape(T);
(%o2)                        [42, 5]
(%i3) df_register(T, "sales")$
(%i4) R : df_sql("SELECT region, sum(price) AS total FROM sales GROUP BY region")$
(%i5) df_table_names(R);
(%o5)                    [region, total]

See also: df_sql_run, df_register


df_sql_run (query) — Function

Execute a DuckDB SQL statement that produces no result (DDL, INSERT, etc.).

Examples

(%i1) df_sql_run("CREATE TABLE temp AS SELECT * FROM read_csv('data.csv')")$
(%i2) T : df_sql("SELECT * FROM temp WHERE x > 0")$

See also: df_sql


df_register (T, name) — Function

Register a df_table as a DuckDB table, making it available for SQL queries by name. Re-registering the same name replaces the previous registration.

Examples

(%i1) T : df_table(["x", "y"],
                    [ndarray([1.0, 2.0, 3.0]), ndarray([10.0, 20.0, 30.0])])$
(%i2) df_register(T, "mydata");
(%o2)                         done
(%i3) R : df_sql("SELECT * FROM mydata WHERE x > 1")$
(%i4) df_table_shape(R);
(%o4)                        [2, 2]

See also: df_unregister, df_sql


df_unregister (name) — Function

Remove a previously registered DuckDB table.

Examples

(%i1) df_unregister("mydata");
(%o1)                         done

See also: df_register


df_duckdb_filter (T, where_clause) — Function

Filter table rows using a DuckDB SQL WHERE clause. Faster than df_filter for large tables. Accepts SQL expressions, not Maxima lambdas.

Examples

(%i1) T : df_table(["name", "price"],
                    [df_string_column(["A", "B", "C"]), ndarray([10.0, 30.0, 20.0])])$
(%i2) T2 : df_duckdb_filter(T, "price > 15")$
(%i3) df_table_shape(T2);
(%o3)                        [2, 2]
(%i4) df_duckdb_filter(T, "price > 15 AND name = 'B'")$

See also: df_filter, df_duckdb_arrange


df_duckdb_arrange (T, column) / df_duckdb_arrange (T, column, descending) — Function

Sort table rows using DuckDB. Ascending by default; pass descending for reverse order.

Examples

(%i1) T2 : df_duckdb_arrange(T, "price")$
(%i2) df_to_string_list(df_table_column(T2, "name"));
(%o2)                      [A, C, B]
(%i3) T3 : df_duckdb_arrange(T, "price", descending)$
(%i4) df_to_string_list(df_table_column(T3, "name"));
(%o4)                      [B, C, A]

See also: df_arrange, df_duckdb_filter


df_duckdb_join (T1, T2, key) / df_duckdb_join (T1, T2, key, left) — Function

Join two tables using DuckDB. Inner join by default; pass left for a left join.

Examples

(%i1) T1 : df_table(["id", "name"],
                     [df_string_column(["1", "2", "3"]),
                      df_string_column(["Alice", "Bob", "Charlie"])])$
(%i2) T2 : df_table(["id", "score"],
                     [df_string_column(["1", "2"]), ndarray([90.0, 80.0])])$
(%i3) df_table_shape(df_duckdb_join(T1, T2, "id"));
(%o3)                        [2, 3]
(%i4) df_table_shape(df_duckdb_join(T1, T2, "id", left));
(%o4)                        [3, 3]

See also: df_inner_join, df_left_join


df_duckdb_group_summarize (T, group_col, name1, expr1, …) — Function

Group and aggregate using DuckDB SQL. Takes alternating result-name / SQL-expression string pairs. Much faster than df_group_by + df_summarize for large tables.

Examples

(%i1) T : df_table(["region", "revenue"],
                    [df_string_column(["N", "S", "N", "S", "N"]),
                     ndarray([10.0, 20.0, 30.0, 40.0, 50.0])])$
(%i2) R : df_duckdb_group_summarize(T, "region",
             "total", "sum(revenue)",
             "avg_rev", "avg(revenue)",
             "n", "count(*)")$
(%i3) df_table_shape(R);
(%o3)                        [2, 4]
(%i4) df_table_names(R);
(%o4)              [region, total, avg_rev, n]

See also: df_group_by, df_summarize


df_duckdb_status () — Function

Report whether the DuckDB connection is active. Returns true or false.

Examples

(%i1) df_duckdb_status();
(%o1)                        false
(%i2) df_sql("SELECT 1")$
(%i3) df_duckdb_status();
(%o3)                         true

See also: df_duckdb_close


df_duckdb_close () — Function

Close the session DuckDB connection and database. The connection is automatically re-created on the next DuckDB operation.

Examples

(%i1) df_duckdb_close();
(%o1)                         done
(%i2) df_duckdb_status();
(%o2)                        false

See also: df_duckdb_status