rocuinneagain
Forum Replies Created
-
rocuinneagain
MemberMay 21, 2024 at 9:12 am in reply to: pykx pandas.read_html() fails to convert string to html tablePyKX converts a q CharVector to Python NumPy array of bytes by default.
https://code.kx.com/pykx/2.5/pykx-under-q/upgrade.html#functional-differences
q).pykx.eval["lambda x: print(type(x))"][test]; <class 'numpy.ndarray'> q).pykx.eval["lambda x: print(x)"][test]; [b'<' b't' b'a' b'b' b'l' b'e' b'>' b'<' b't' b'r' b'>' b'<' b't' b'h' ...
You can create a helper to convert to strings as you require:
q)b2s:.pykx.eval["lambda x: x.tobytes().decode('UTF-8')"] q).pykx.print pd[`:read_html]b2s[test] [ First Name Last Name Age 0 John Doe 30 1 Jane Smith 25 2 Emily Jones 22]
More info on default conversions:
https://code.kx.com/pykx/2.5/pykx-under-q/intro.html#function-argument-types
And:
https://code.kx.com/pykx/2.5/user-guide/fundamentals/text.html
-
rocuinneagain
MemberMay 20, 2024 at 8:45 am in reply to: abs() vs abs[] for fby “while” all() vs all[]<div>See these sections of docs on:</div>
Order of evaluation also matters: Left-of-Right Evaluation
abs(price)=({abs max x};price)
Will run in order:
- ({abs max x};price)
- (price)=({abs max x};price)
- abs(price)=({abs max x};price)
whereas:
abs[price]=({abs max x};price)
Will run in order:
- ({abs max x};price)
- abs[price]
- abs[price]=({abs max x};price)
This tries to pass 2 arguments to all which only takes one argument so you get a rank error
https://code.kx.com/q/ref/all-any/#all
all[col=a;col2=b]
-
You could make windows like so:
q)start:0D q)duration:1D q)length1:0D00:20 q)length2:0D00:10 q)windows:{flip (0;y-1)+\:y*til `long$x div y}'[duration;(length1;length2)] q)(first;last)@\:windows 0 0D00:00:00.000000000 0D00:19:59.999999999 0D23:40:00.000000000 0D23:59:59.999999999 q)(first;last)@\:windows 1 0D00:00:00.000000000 0D00:09:59.999999999 0D23:50:00.000000000 0D23:59:59.999999999 q)t:([] time:100?1D;sym:100?`A`B`C) time sym ------------------------ 0D11:37:38.441374450 A 0D16:23:13.911677598 A 0D03:40:38.809463381 C 0D12:50:31.973013281 B 0D10:58:33.142468035 C 0D00:11:36.601854264 B
Query for small tables for each sym for each windows:
syms:exec distinct sym from t q){[x;y;z] select from x where sym=y,time within z}[t](.)/:syms cross enlist each windows 0 +`time`sym!(`timespan$();`symbol$()) +`time`sym!(,0D03:19:44.361107647;,`A) +`time`sym!(0D03:20:29.103351384 0D03:28:31.211699992;`A`A) ... +`time`sym!(,0D20:47:50.484825968;,`B) +`time`sym!(,0D21:14:37.927203476;,`B) +`time`sym!(0D21:39:42.773356139 0D21:37:00.400066673;`B`B) +`time`sym!(`timespan$();`symbol$()) +`time`sym!(,0D22:09:45.092769563;,`B)
-
The is a kdb+ Solace interface
- https://solace.com/kx/
- https://github.com/KxSystems/solace/tree/master
- https://code.kx.com/q/wp/solace/
One of the getPayloadAs* functions may be what you need
https://github.com/KxSystems/solace/blob/77dd10edefa014f39b6c5ed9a693bdcad7685509/q/solace.q#L30
q)msg "\PAR1\025\004\025\010...
q).solace.getPayloadAsBinary msg
-
, rather than ; separating the arguments of fbis. Otherwise runs fine:
q)fbis:{[c_;x0;p_]{[xn ;c;p] xn-((xn xexp p)-c)%(p*xn xexp p-1)}[;c_;p_]\[x0]}
q)fbis[2;1;3]
1
1.333333
1.263889
1.259933
1.259921
1.259921
-
Linux is best to make use of all features.
If you plan on using Platform/Developer I’d recommend Ubuntu 20.04 for best compatibility.
https://code.kx.com/developer/getting-started/#prerequisites
-
Dictionaries require lists to be passed to either side of !. You can use enlist to make lists from atoms:
q)d:.Q.def[enlist[`num1]!enlist 5].Q.opt .z.x
q)d
num1| 5If you are using kdb 4.1 you can use the new dictionary syntax which does not need enlist
q)d:.Q.def[([num1:5])].Q.opt .z.x
q)d
num1| 5 -
rocuinneagain
MemberApril 29, 2024 at 8:36 am in reply to: kx developer – from installation to the endYou need to install q to use developer. q cannot be installed by pip.
Instructions are here: https://code.kx.com/q/learn/install/
code.kx.com
Installing kdb+ | Learn | kdb+ and q documentation - Kdb+ and q documentation
How to install kdb+ on Linux, macOS, or Windows
-
rocuinneagain
MemberApril 23, 2024 at 11:50 am in reply to: Failed to Load KX Insights Core Library error when using pykx in qDid you download q from this link?
https://kx.com/kdb-personal-edition-download/
It does not include the cloud libraries.
Instead the insights edition is needed to have those libraries:
https://kx.com/kdb-insights-personal-edition-license-download/
-
rocuinneagain
MemberMay 21, 2024 at 8:30 am in reply to: KX Dashboards “Windows cannot find ‘node’…”Node.js is required for the upload server.
If node is not installed, dashboards will work as normal without the upload component.
Documentation will be updated to detail this.
-
Going forward PyKX under q is the recommended replacement for embedPy.
*It is not operational yet on Windows
-
The first error is saying you do not have node.js installed to be able to run that command
https://nodejs.org/en/download
The second error is saying that a different process is using the port 10001 blocking your new process from starting. You need to kill that other process or change your configuration to use a different port instead.
nodejs.org
Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine.
-
rocuinneagain
MemberApril 29, 2024 at 8:20 pm in reply to: kx developer – from installation to the endYou have not exported PATH so q is available on it.
See: https://code.kx.com/q/learn/install/#step-5-edit-your-profile
setx PATH "%PATH%;C:\q\w64"
Or instead to make a permanent change to the existing PATH environment variable on windows you can follow this guide https://chlee.co/how-to-setup-environment-variables-for-windows-mac-and-linux/
code.kx.com
Installing kdb+ | Learn | kdb+ and q documentation - Kdb+ and q documentation
How to install kdb+ on Linux, macOS, or Windows
-
rocuinneagain
MemberApril 23, 2024 at 1:06 pm in reply to: Failed to Load KX Insights Core Library error when using pykx in qRun ‘ls’ on ‘/q’ in the container to see what files are there. The load error output suggests the cloud libraries are not there.