marrowgari
marrowgari

Reputation: 427

PyQ: How to enumerate symbol column on a splayed table?

I'm trying to create a splayed table with a symbol column using pyq. In q I would set the table by enumerating the symbol column with .Q.en...

:splay/ set .Q.en[`:splay;]([]a:`x`y`z; b:1 2 3)

I tried a few variations of the following...

q.set(':splay/', q('.Q.en')('!', ["Name", "Ask", "Bid", "Last", "Vol", "Time"], [K.symbol([]), K.float([]), K.float([]), K.float([]), K.float([]), K.timestamp([])]).flip)

But it throws the following rank error: _k.error: rank.

What is the proper syntax for this in pyq?

Upvotes: 1

Views: 204

Answers (1)

Alexander Belopolsky
Alexander Belopolsky

Reputation: 2268

First, your q code is incorrect. The function

.Q.en[`:splay;]

will place the sym file inside the splay table and this is not what you want. Instead, the sym file should be saved in the top database directory (db in the code below) next to the splay table.

`:db/splay/ set .Q.en[`:db]([]a:`x`y`z; b:1 2 3)

The same code can be written in pyq as

q.set(':db/splay/', q('.Q.en', ':db', q('([]a:`x`y`z; b:1 2 3)')))

Upvotes: 3

Related Questions