4

Following the documentation, I tried to do the following:

t:([]a:1 2 3;b:4 5 6;c:`d`e`f) // some input table
`a`b _ t                       // works: delete NOT in place
(enlist `a) _ t                // works: delete NOT in place
t _:`a`b                 // drop columns in place does not work; how to make it to work?
// 'type
//   [0]  t _:`a`b

Thank you very much for your help!

isherwood
  • 58,414
  • 16
  • 114
  • 157
S.V
  • 2,149
  • 2
  • 18
  • 41

3 Answers3

7

You should be able to use

delete a,b from `t

to delete in place (The backtick implies in place).

Alternatively, for more flexibility you could use the functional form;

![`t;();0b;`a`b]
Michael K
  • 226
  • 1
  • 5
3

The simplest way to achieve column deletion in place is using qSQL:

t:([]a:1 2 3;b:4 5 6;c:`d`e`f)

delete a,b from `t -- here, the backtick before t makes the change in place.

q)t
c
-
d
e
f
kylebonnes
  • 936
  • 2
  • 7
0

Michael & Kyle have covered the q-SQL options; for completeness, here are a couple of other options using _:

Using _ as in your question, you can re-assign this back to t e.g.

t:`a`b _ t

You can also use . amend with an empty list of indexes i.e. "amend entire", which can be done in-place by passing `t or not in-place by passing just t e.g.

q).[t;();`a`b _] / not in-place
c
-
d
e
f
q).[`t;();`a`b _] / in-place
`t
q)t
c
-
d
e
f
Jonathon McMurray
  • 2,881
  • 1
  • 10
  • 22