I am new to KDB and cannot understand why i can access the order column for the table stocks but not trader. The below is my code with the error.
q)trader
item brand | price order
---------------| -----------
soda fry | 1.5 200
bacon prok | 1.99 180
mushroom veggie| 0.88 110
eggs veggie| 1.55 210
tomatoes veggie| 1.35 100
q)trader.order
'order
[0] trader.order
^
q)stock.order
50 82 45 92
q)stock
item brand price order
---------------------------
soda fry 1.5 50
bacon prok 1.99 82
mushroom veggie 0.88 45
eggs veggie 1.55 92
q)trader.order
'order
[0] trader.order
^
Your table trader
is keyed and you cannot use trader.order
to select the order column.
You can use this instead if you want
(0!trader)`order
The reason is because when you do trader.order
what you actually do is you use indexing. It's the same as if you'd do list.index
. A table is just a list of dictionaries and you use dot(.)
to index into it. However a keyed table does not have the same structure so you'll have to unkey it first.