1

Expanding this question,

kdb+: replace null integer with 0

Ff I have a large table that contains different data types like float, int, timestamps, how can I expand this

0^tbl

to only get applied to columsn of a certain type. Currently, if I apply it to the full table, I get a type error and there must eb a smarter way than doing it column by column manually

1 Answer 1

4

You can do this using a functional apply based on the type of each column, something like the following:

q)t:([] a:9?`3;b:9#0N;c:9#0Nf;d:9#0Ni)
q)@[t;where (type each flip t) within 5 9h;0^]
a   b c d
---------
kdj 0 0 0
eeg 0 0 0
nce 0 0 0
jog 0 0 0
..

This works by applying 0^ to only the columns with types between 5 and 9 (i.e. short, int, long, real and float)

Hope this helps

Jonathon

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.