0

Is there a way in KDB/pykx to get only some columns as raw data while get others converted to pandas types?

In the example below, I want to be able to do what is shown in the last line (for variable d3), i.e. only get some columns as raw data:

import pykx as kx
q = kx.SyncQConnection(host = 'localhost', port = 8888, timeout = 888.8)
cmd = 'select from table where date=2025.04.30'
d1 = q(cmd).pd() # all columns converted to pandas types
d2 = q(cmd).pd(raw=True) # all columns returned as raw data
d3 = q(cmd).pd(raw=['col1','col2','col3']) # is it possible to get only some columns as raw ?

1 Answer 1

2

Not directly but you can split out the table if you need

>>> import pykx as kx
>>> conn = kx.SyncQConnection(port = 5000)
>>> t = conn('([] t1:2#.z.p;t2:2#.z.p)')
>>> raw_cols=['t1']
>>> import pandas as pd
>>> pd.concat([t[raw_cols].pd(raw=True),t[[x for x in t.columns.py() if x not in raw_cols]].pd()], axis=1)
                   t1                            t2
0  806425367952914225 2025-07-21 15:02:47.952913654
1  806425367952914225 2025-07-21 15:02:47.952913654
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.