1

I am using qpython to query into a KDB+ database and then performing operations on the output. old_df is output from an earlier qpython sync query which has '[source_id]' as a string column. Now am querying into another database trades_database which has the same fields (as source_id) under a different column name customer (also string, no issues in data type)

params = np.array([])
for i in old_df['source_id']:
    params = np.append(params, np.string_(i))

new_df = q.sync('{[w]select from trade_database where customer in w}', *params, pandas=True)

Unfortunately, there is very little available online to solve such queries. I have learned a fair bit from the questions asked in here, but am really stuck here. My list could be very long and so would need to write a query where it is taken as an input only.

I also tried:

new_df= q1.sync('{select from trades_database where customer in (`1234, `ABCD)}', pandas=True)

which works but I get <qpython.qtype.QLambda object at 0x000000000413F710>

How does one "unpack" a QLambda object?

Please ignore the 2nd question if I am not allowed to ask 2 questions in the same post pls. Apologies in that case.

Thanks!

1 Answer 1

2

here is what I did and it seems to work:

    params = np.array(one_id) #just input the initial id used to search for old_df, and not put the square brackets to make it into a list

    for i in old_df['source_id']:
        params = np.append(params,np.string_(i))
    params=np.unique(params)

    new_df = q1.sync('{[w]select from trades_database where customer in w}', params, pandas=True)
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.