I have a splayed Kdb database of symbols, floats, and timestamps. I'd like to convert this to NumPy arrays. However using the following code...
>>> import numpy as np
>>> from pyq import q
>>> d = q.load(':alpha/HDB/')
>>> a = np.array(d)
Returns this error...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/marrowgari/py3/lib/python3.6/site-packages/pyq/_n.py", line 158, in array
return numpy.array(list(self), dtype)
TypeError: iteration over a K scalar, t=-11
Is this because Kdb symbol types do not have a direct analogue in NumPy? If so, how do I correct this?
Suppose your HDB was created as follows:
Then, first of all you should load it using
\lcommand, not the load function:This will load all your tables and enumeration domains.
Now you should be able to convert the sym column of your table to a numpy array of strings
or to a numpy array of integers:
You can also convert the entire table to a numpy record array in one go, but you will have to "map" it into the memory first: