Although take with lists seems to work fine, drop seems to have an issue. Thoughts?
q)show rct:(a
bc!1 2 3;
ab
c!4 5 6)!x
y
a b c|
-----| -
1 2 3| x
4 5 6| y
/ produce dictionary (bug?)
q)(enlist 1 2 3)_rct
1 2 3| x
4 5 6| y
/ produce right-cross-tab
q)(enlista
b`c!1 2 3)_rct
a b c|
-----| -
4 5 6| y
q)show kt2:([a:10 40;b:20 50;c:30 60]z1:x
y;z2:i
j)
a b c | z1 z2
--------| -----
10 20 30| x i
40 50 60| y j
/ produce left-cross-tab (bug?)
q)(enlist 10 20 30)_kt2
| z1 z2
--------| -----
10 20 30| x i
40 50 60| y j
/ produce keyed-table
q)(enlista
b`c!10 20 30)_kt2
a b c | z1 z2
--------| -----
40 50 60| y j
Hi ,
Correct me if I’m wrong, but I don’t seem to be getting the same outputs as you?
Thanks,
Megan
Hi Megan,
Thank you for your reply. Yes it seems like the headers are a bit different (strange) but drop using a list is still not working correctly as far as I can tell.
Heres the version I am using: KDB+ 4.0 2023.08.11 Copyright (C) 1993-2023 Kx Systems
Hi again Megan,
I went ahead and tried the expressions out again with a clean copy of the interpreter and now I am getting the same values as you are which still seem to be incorrect for the two cases with the drop using a naked list (the ones with dictionaries as the left operand seem to work).
Any ideas why these two cases do not seem to work correctly? I can only assume I corrupted the interpreter last time around to get the differing results. Thanks.
For completeness here are the results produced with take (#) – they seem to be correct:
q)show rct:(a
bc!1 2 3;
ab
c!4 5 6)!x
y
a b c|
-----| -
1 2 3| x
4 5 6| y
/ produce dictionary
q)(4 5 6;1 2 3)#rct
4 5 6| y
1 2 3| x
/ produce right-cross-tab
q)(a
bc!4 5 6;
ab
c!1 2 3)#rct
a b c|
-----| -
4 5 6| y
1 2 3| x
q)show kt2:([a:10 40;b:20 50;c:30 60]z1:x
y;z2:i
j)
a b c | z1 z2
--------| -----
10 20 30| x i
40 50 60| y j
/ produce left-cross-tab
q)(40 50 60;10 20 30)#kt2
| z1 z2
--------| -----
40 50 60| y j
10 20 30| x i
/ produce keyed-table
q)(a
bc!40 50 60;
ab
c!10 20 30)#kt2
a b c | z1 z2
--------| -----
40 50 60| y j
10 20 30| x i
If you take a look at how the results change from a dict, right cross-tab, left cross-tab, and keyed table based on the left operand I’m not even sure what the correct answers would be with the drop expressions. Any ideas? Should all the drops produce keyed tables or something else? It’s not very clear.