'KDB embedPy use array from Q in Python

I am using JupyterQ and have two 2 tables in q:

tbl1: ([]month:(1997.01;1997.01;1997.01);
    ric:(3#`GTGS.SI);
    date:(1997.01.06T01:19:21.160;1997.01.06T01:53:57.230;1997.01.06T07:24:19.240);
    price:(0.71;0.72;0.73));

tbl2: ([]month:(1997.01;1997.01;1997.01);
    ric:(3#`NSWF.SI);
    date:(1997.01.06T01:19:21.160;1997.01.06T01:53:57.230;1997.01.06T07:24:19.240);
    price:(0.45;0.46;0.47));

I have a class teCalc defined in python.

I want to pass to it two arrays as follows (in python): teCalc.addObservations(tbl1, tbl2)

How do I pass those q tables to the class in python?

The following function:

print .p.import[`numpy;`:array][tbl1]

gives me:

{'month': array([1997.01, 1997.01, 1997.01]), 'ric': ['GTGS.SI', 'GTGS.SI', 'GTGS.SI'], 'date': array([-1089.94489398, -1089.92086539, -1089.69144398]), 'price': array([0.71, 0.72, 0.73])}

So I can see that it is possible to convert the table in q to a python object.

However, all my attempts to assign it to a variable in python have failed. If I reference either tbl1 or tbl2 in a python line of code in JupyterQ (for example p)print(tbl1)) then the tbl1 variable name isn't recognised.

Please do advise. How do I use data from Q on a class created in Python in JupyterQ?

Thanks and regards,

Simon



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source