q lang - How do I add several columns at once in kdb? -
Anyhow, I can only find examples showing how to add a column.
So I wrote this code, which works, but I know that there is a better way to do this: the table exists with the column already filled with data, and add new columns to me Which are initially zero.
T: Update column 1: `t; T: Update column 2: `t from; T: Update column 3: `t; T: Update column 4: `t from; I tried to create a function like this:
colNames: `column1` column2`column3`column4; T: {update x: `each colNamesList; But it only adds one column and it's called X.
Any suggestions to improve this code will greatly appreciate. I just have to add a lot more than 4 columns and my code is very long. Thanks!
Several ways to get it ....
Newcols: `col3`col4; Q) @ [Tab; Newcale;:;]] call 1 call 2 coal 3 coal 4 ------------------- a1b2c3 Also can specify different types
q) @ [tab; Newcomers ;: (`; 0N)] col1 col2 col3 col4 ------------- ------ a 1b2c3 or Make a functional update
q)! [`Tab; (); 0b; Newcols! Count [newcols] #enlist (), `]` tab
Comments
Post a Comment