kdb+

Converting 0N values to the correct null for each data type


So I have 0N values which represents no previous data for that sid, the issue is, is that the 0N is showing up in symbol cols too and I want to convert each case to the null value for the data type it is in.

So i've got sid's like

`aapl
`tsla
0N
`jpm

etc.

q)exec price from tb
73.02837
75.29633
71.66759
70.30682
70.30682
67.13167
62.14215
0N
0N
72.12119
78.92507
0N
65.77089
73.93556
0N
0N
0N
0N
72.12119
0N
0N
0N
73.93556
73.02837
0N
0N
0N
70.76041
73.02837
73.02837
60.32779
0N
69.85322
0N
61.23497
0N
63.95652
70.30682
0N
60.32779

Solution

  • If you have 0N in symbol columns as well it means you have a mixed type column, which is generally not a great idea. Otherwise you can use fills o forward fill your column