Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

KDB+/Q: How does one select all items (keys+values) of a dictionary where the respective value conforms to a condition?

Tags:

kdb+

How does one filter the items of a dictionary based on the values therein. For instance, given the following dictionary:

990.5| 0
900.5| 0
600.5| 300
600  | -300

How does one filter out all instances therein where the value = 0. The result thereafter being:

600.5| 300
600  | -300

Thanks

like image 231
James Avatar asked Dec 05 '25 04:12

James


1 Answers

The where keyword can also be used to achieve this without assignment

q)d:990.5 900.5 600.5 600!0 0 300 -300
q)where[d<>0]#d
like image 107
cillianreilly Avatar answered Dec 06 '25 21:12

cillianreilly



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!