Back to Converting Dictionaries to Tables

Dictionaries · Converting Dictionaries to Tables · Practice Question

Create a table from conforming dictionaries

Sign in to track your progress

Question

Given the following two dictionaries:

p:`a`b`c!(`AAPL;10.0;123i)

g:`a`b`c!(`MSFT;20.5;456i)

Create a table containing the data from both dictionaries.

Solution

Method 1

(p;g)

Method 2

(enlist p),enlist g

Result:

a    b    c
-------------
AAPL 10   123
MSFT 20.5 456

Explanation

p and g both have keys `a`b`c, so they conform and (p;g) is auto-promoted to a table (type (p;g) is 98h). (enlist p),enlist g builds the same 2-item list explicitly via Join.

.Q.s1 (p;g) shows the table's underlying column-dictionary form: "+`a`b`c!(`AAPL`MSFT;10 20.5;123 456i)".