Qu

table

Builtin index · Collections & strings

result = DataFrame(name=values, ...)

Input: name, ... · Output: result

What it is

Each named argument is a column: values is either a numeric Vec / List of Str (a real column) or a scalar number/Str (broadcast to every row). Builds a Table from the named columns, in the order the arguments were written; a scalar/string column broadcasts to the row count set by whichever columns are actual vectors, and vector columns must all agree in length.

Overloads

One call shape — this function is not overloaded.

CodeInputOutputDescription
result = DataFrame(name=values, ...)
name — (default values)not documented yet
... repeatablenot documented yet
result Table
Returns a Table.

Examples

From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.

alloys = table("
    name  | density | modulus
    steel | 7.85    | 200
    alu   | 2.70    | 69
", sep = "|")
print(alloys)
output
name   density  modulus
-----  -------  -------
steel     7.85      200
alu        2.7       69

from collections-strings

st = table(a = [1.0, 2.0, 3.0], b = [10.0, 20.0, 30.0], label = ["x", "y", "z"])
print("standardize on a table, per numeric column (label untouched):")
print(standardize(st))
output
standardize on a table, per numeric column (label untouched):
 a   b  label
--  --  -----
-1  -1  x    
 0   0  y    
 1   1  z    

from statistics-ml

runs = table(
    channel  = [1, 2, 3],
    baseline = [0.412, 0.508, 0.377],
    treated  = [0.240, 0.301, 0.219]
)
runs = insert_column(runs, "reduction", 1 - runs.treated / runs.baseline)
print(runs)
output
channel  baseline  treated  reduction
-------  --------  -------  ---------
      1     0.412     0.24   0.417476
      2     0.508    0.301    0.40748
      3     0.377    0.219   0.419098

from from-zero

runs = table("
    channel, baseline, treated
    1,       0.412,    0.240
    2,       0.508,    0.301
    3,       0.377,    0.219
")
print(runs)
print(mean(runs.baseline))
output
channel  baseline  treated
-------  --------  -------
      1     0.412     0.24
      2     0.508    0.301
      3     0.377    0.219
0.432333

from collections-strings

See also

DataFrame — documented in the same entry.