On this page:
column-df
row-df

1 Constructing data-frames🔗ℹ

These are constructors for data-frames that may be more ergonomic than make-data-frame. Generally, while doing data analysis, you want to use df-read/csv or a similar function to read in real-world data from some source. If you are constructing data from a Racket program, however, these may be useful.

syntax

(column-df [column-name column-data] ...)

 
  column-name : (or/c identifier? string?)
  column-data : vector?
Constructs a data-frame with the given column-names, with each column-data as the data in each column.

column-name can either be an identifier or an expression that evaluates to a string. If it is an identifier, it will be taken literally.

Example:
> (show (column-df [x (vector 1 2 3)]
                   [(string-append "a" "b") (vector "a" "b" "c")]))

data-frame: 3 rows x 2 columns

┌─┬──┐

│x│ab│

├─┼──┤

│1│a │

├─┼──┤

│2│b │

├─┼──┤

│3│c │

└─┴──┘

syntax

(row-df [column-name ...] value ...)

Constructs a data-frame with the given column-names, row-by-row with the given values.

This method runs in quadratic time, but it is executed solely at compile time, so its performance should be roughly equivalent to that of column-df.