cols
, xcol
, xcols
¶
Table columns
cols
¶
Column names of a table
cols x cols[x]
Where x
is a
- table
- the name of a table as a symbol atom
- a filesymbol for a splayed table
returns as a symbol vector its column names.
q)\l trade.q
q)cols trade /value
`time`sym`price`size
q)cols`trade /reference
`time`sym`price`size
xcol
¶
Rename table columns
x xcol y xcol[x;y]
Where y
is a table, passed by value, and x
is
- a symbol vector of length no greater than
count cols y
returnsy
with its firstcount x
columns renamed - a dictionary (since V3.6 2018.08.24) formed from two symbol vectors, of which the keys are all the names of columns of
y
, returnsy
with columns renamed according to the dictionary
q)\l trade.q
q)cols trade
`time`sym`price`size
q)`Time`Symbol xcol trade / rename first two columns
Time Symbol price size
------------------------------
09:30:00.000 a 10.75 100
q)trade:`Time`Symbol`Price`Size xcol trade / rename all and assign
q)cols trade
`Time`Symbol`Price`Size
q)(`a`c!`A`C)xcol([]a:();b:();c:()) / rename selected columns
A b C
-----
Q for Mortals
§9.8.1 xcol
xcols
¶
Reorder table columns
x xcols y xcols[x;y]
Where
y
is a simple table, passed by valuex
is a symbol vector of some or all ofy
’s column names
returns y
with x
as its first column/s.
q)\l trade.q
q)cols trade
`time`sym`price`size
q)trade:xcols[reverse cols trade;trade] / reverse cols and reassign trade
q)cols trade
`size`price`sym`time
q)cols trade:`sym xcols trade / move sym to the front
`sym`size`price`time
Q for Mortals
§9.8.2 xcols
meta
,
.Q.V
(table to dictionary)
Dictionaries,
Metadata
Tables