Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Null float to KDB+ converts to empty string #50

Open
dberrios2000 opened this issue May 11, 2017 · 3 comments
Open

Null float to KDB+ converts to empty string #50

dberrios2000 opened this issue May 11, 2017 · 3 comments

Comments

@dberrios2000
Copy link

dberrios2000 commented May 11, 2017

I am currently using python 2.7.12 using qpython 1.2.2, numpy 1.10.4.

Running the following script does not send a NAN float datatype to KDB+ but instead an empty string.

from qpython.qtype import qnull,QDOUBLE,QFLOAT,_QNAN64
from qpython import qconnection
import numpy

q = qconnection.QConnection(host = 'localhost', port = 5010)
q.open()
q.sync('foo',numpy.string_('test_trade'),[numpy.string_('PYTHON'),qnull(QDOUBLE)])
or
q.sync('foo',numpy.string_('test_trade'),[numpy.string_('PYTHON'),_QNAN64])

KDB+ 3.3 2015.11.03 :
q)foo:{[x;y] show y}
q)IBM " " 2nd example: q.sync('foo',numpy.string_('test_trade'),[numpy.string_('IBM'),qnull(-7)]) q)IBM
0N

Seems like a bug when trying to send a null float datatype .

@dberrios2000 dberrios2000 changed the title Sending null float sending empty string to kdb+ Null float to KDB+ converts to empty string May 11, 2017
@dberrios2000
Copy link
Author

Does anyone know why sending
q.sync('foo', numpy.string_('test_trade'),[numpy.string_('PYTHON'),numpy.fromstring(_QNAN64)]) would send KDB a value of ,0n

@maciejlach
Copy link
Collaborator

Hi @dberrios2000

it looks like there is a bug connected with Pandas integration. When serializing generic lists, NaN values are converted to single space.

Before the patch is available and pulled by the maintainer, please use this workaround:

from qpython.qtype import qnull, QDOUBLE
from qpython import qconnection
from qpython.qwriter import QWriter

with qconnection.QConnection(host = 'localhost', port = 5000, writer_class = QWriter) as q:
  q.sync('foo', 'table', ['PYTHON', qnull(QDOUBLE)])

This enforces qpython to use default, non-pandas serializer, even if the pandas package is installed.

Best regards
Maciej

maciejlach added a commit to maciejlach/qPython that referenced this issue May 12, 2017
@dberrios2000
Copy link
Author

This worked.. thank you for your help.

SKolodynski added a commit that referenced this issue Dec 5, 2018
Fix: serialization of 0n in generic lists (when Pandas package is installed) (#50)
nugend pushed a commit to nugend/qPython that referenced this issue Jul 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants