exxeleron / qPython

interprocess communication between Python and kdb+
http://www.devnet.de
Apache License 2.0
152 stars 89 forks source link

`QFLOAT_LIST` in `MetaData` produces `real` KDB+ data type not `float` #24

Closed danielkrizian closed 9 years ago

danielkrizian commented 9 years ago

Enforcing the data type as QFLOAT_LIST doesn't seem to work, as the KDB+ result is real (e), not float (f). Am I missing something?

from pandas import Series,DataFrame
import numpy as np
import qpython.qconnection as qconnection
from qpython import MetaData
from qpython.qtype import QFLOAT_LIST

d = {'col' : Series([1., 2.2, 3.45, 4.6564])}
tbl = DataFrame(d)
tbl[['col']].astype(np.float)
tbl.meta = MetaData(col = QFLOAT_LIST)
q = qconnection.QConnection(host = '10.10.4.220', port = 5000, pandas = True)
q.open()
q('set', numpy.string_('tbl'), tbl)
q('meta tbl')

#      t f a
# c         
# col  e    

Thank you

maciejlach commented 9 years ago

You have to use QDOUBLE_LIST instead of QFLOAT_LIST to enforce conversion to kdb+ float f list. The QFLOAT_LIST actual enforces conversion to kdb+ real e list.

In order to maintain consistency with other interfaces (qJava, qSharp) and 3rd party code relying on these we decided to keep naming of the QFLOAT, QDOUBLE, QFLOAT_LIST and QDOUBLE_LIST type codes inline with IEEE 754 standard.

danielkrizian commented 9 years ago

Thank you Maciej, makes sense.