【问题标题】:Can't retrieve symbols from KDB using QPython无法使用 QPython 从 KDB 检索符号
【发布时间】:2021-09-29 07:35:19
【问题描述】:

我正在尝试将 KDB 表拉入 python 数据框。表创建成功,所有float列可见但symbol列为空。

我正在使用:

with qconnection.QConnection(host = 'XXXX', port = 5001, pandas = True) as q:
   df = q.sync('table')

此表上的元显示字符串列的类型为“s”。表的类型是 98h。 我正在使用 python 3.7。

有人遇到过这种情况吗?

【问题讨论】:

  • 当您通过 IPC 查询时,这些符号应该会自动取消枚举,但也许这没有发生?您可以尝试在选择中对符号列进行字符串化,以查看是否可以获得字符串形式的符号:df = q.sync('update string symcol1, string symcol2 from table')。如果您可以使用此方法看到字符串,那么它指向的是符号的反枚举
  • 感谢您的回复!它也不适用于字符串。还尝试将之前出现的时间戳串起来,这会使它们消失。
  • 有趣。您确定 qpython 与 python 3.7 兼容吗?我对 qpython 不太熟悉(我使用 pyq)所以我不确定你是否需要对符号/字符串做一些特殊的事情
  • 我可以尝试在 3.6 上使用它。让我尝试使用 pyq,以前从未使用过它。谢谢!

标签: pandas dataframe kdb qpython


【解决方案1】:

我同意 Terry 的观点,即这可能是使用带有 qpython 的 python 3.7 的问题。该项目已经处于维护模式一段时间了,在他们的 github 页面 https://github.com/exxeleron/qPython

上发现了很多问题

你能试试这个,看看返回了什么?它看起来在 python 3.6 上运行良好

#open a q session with 'q -p 5000' on localhost
from qpython import qconnection
import pandas as pd
import sys

q = qconnection.QConnection(host = 'localhost', port = 5000, pandas = True)
q.open()
df = q.sendSync('flip `nums`syms`strings!(1 2;`hello`world;("hello";"world"))')
print(df)
print(df.dtypes)
print(df.meta)
print(sys.version)

#the return using python 3.6, kdb 4.0 and qpython from anaconda
   nums      syms   strings
0     1  b'hello'  b'hello'
1     2  b'world'  b'world'
nums        int64
syms       object
strings    object
dtype: object
metadata(qtype=98, nums=7, syms=11, strings=0)
3.6.12 |Anaconda, Inc.| (default, Sep  8 2020, 23:10:56) 
[GCC 7.3.0]

【讨论】:

  • 非常感谢!今天试一试,我会告诉你它是否有效。
猜你喜欢
  • 1970-01-01
  • 2017-12-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-01-14
相关资源
最近更新 更多