Closed JebadiahJohnson closed 9 years ago
If you want to convert and assign Python object to name in q, you can use builtin set
function:
df = q('flip `name`iq`fullname!(`Dent`Beeblebrox`Prefect;98 42 126;("Arthur Dent"; "Zaphod Beeblebrox"; "Ford Prefect"))')
print df
print df.meta
print q('type', df)
q('set', numpy.string_('dataframe_set'), df)
print q('dataframe_set')
Alternatively, you can define your own function in q which assigns parameter to a global name or use anonymous function, e.g.:
q('{[x;y] x set y}', numpy.string_('dataframe_fun'), df)
print q('dataframe_fun')
Note, that set
function expects name to be a q symbol, thus the parameter in Python call is represented as numpy.string_
.
Thanks for the clarification. I will come back if I have more questions.
Jeff
On Nov 5, 2014, at 4:57 AM, Maciej Lach notifications@github.com<mailto:notifications@github.com> wrote:
If you want to convert and assign Python object to name in q, you can use builtin set functionhttp://code.kx.com/wiki/Reference/set:
df = q('flip name
iqfullname!(
DentBeeblebrox
Prefect;98 42 126;("Arthur Dent"; "Zaphod Beeblebrox"; "Ford Prefect"))')
print df
print df.meta
print q('type', df)
q('set', numpy.string_('dataframe_set'), df) print q('dataframe_set')
Alternatively, you can define your own function in q which assigns parameter to a global name or use anonymous function, e.g.:
q('{[x;y] x set y}', numpy.string_('dataframe_fun'), df) print q('dataframe_fun')
Note, that set function expects name to be a q symbol, thus the parameter in Python call is represented as numpy.string_.
— Reply to this email directly or view it on GitHubhttps://github.com/exxeleron/qPython/issues/15#issuecomment-61783700.
Sorry, prob not the best place to reply, but do you guys do any consulting or bespoke software work? I need to connect to kdb from Tableau, a data visualization product. Tableau expects an ODBC v 3.x connection but kdb only supports 2.x
Regards,
Jeff
From: Maciej Lach [mailto:notifications@github.com] Sent: Wednesday, November 05, 2014 4:57 AM To: exxeleron/qPython Cc: Jeff Burnett Subject: Re: [qPython] insert data? (#15)
Closed #15https://github.com/exxeleron/qPython/issues/15.
— Reply to this email directly or view it on GitHubhttps://github.com/exxeleron/qPython/issues/15#event-188570056.
Hi Jeff, I am sure we could help you there. Please contact me at m.recht at devnet dot de and we could talk about the details.
Regards, Marc
Quick question: how do I insert data and convert from something like a pandas dataframe?
I can do the following:
q('(myHeader:5#myBars)') df = q('(myHeader)') print df print df.meta print q('type', df)
but then if I want to insert the data just returned I run into problems. I am probably not doing this correctly.
q.query(qconnection.MessageType.SYNC, 'myHeader2:', df)
I've tried other ways to insert a pandas dataframe as well. No luck. Any help is greatly appreciated.
Jebadiah