Skip to content

2.5.0

Compare
Choose a tag to compare
@rianoc-kx rianoc-kx released this 24 May 16:13
· 15 commits to main since this release
de7966c

PyKX 2.5.0 has been released. Full release notes can be found here.

Highlights:

  • table.xbar , table.window_join , table.replace
  • Added as_arrow keyword to the .pd() method to use PyArrow backed data types rather than NumPy.
  • Other items of note:
  • PyKX can now be installed to locations with spaces in the file path.
  • Updated libq to 4.0 2024.05.07 and 4.1 to 2024.04.29 for all supported OS's.
  • IPC queries can now pass PyKX Functions like objects as the first query parameter.
  • k4.lic licenses can now be installed using the interactive license helper.
  • To ease license updates, If PyKX fails to start due to a license error it will attempt to replace it's license from KDB_LICENSE_B64 or KDB_K4LICENSE_B64 if you have one set.

The full list including more fixes and improvements is available here.

Examples:

table.window_join

>>> trades = kx.Table(data={
...     'sym': ['ibm', 'ibm', 'ibm'],
...     'time': kx.q('10:01:01 10:01:04 10:01:08'),
...     'price': [100, 101, 105]})
>>> quotes = kx.Table(data={
...     'sym': 'ibm',
...     'time': kx.q('10:01:01+til 9'),
...     'ask': [101, 103, 103, 104, 104, 107, 108, 107, 108],
...     'bid': [98, 99, 102, 103, 103, 104, 106, 106, 107, 108]})
>>> windows = kx.q('{-2 1+\:x}', trades['time'])
    >>> trades.window_join(quotes,
    ...                    windows,
    ...                    ['sym', 'time'],
    ...                    {'ask_minus_bid': [lambda x, y: x - y, 'ask', 'bid'],
    ...                     'ask_max': [lambda x: max(x), 'ask']})
pykx.Table(pykx.q('
    sym time     price ask_minus_bid ask_max
    ----------------------------------------
    ibm 10:01:01 100   3 4           103
    ibm 10:01:04 101   4 1 1 1       104
    ibm 10:01:08 105   3 2 1 1       108
'))

table.xbar

>>> kx.random.seed(42)
>>> tab = kx.Table(data = {
...     'x': kx.random.random(N, 100.0),
...     'y': kx.random.random(N, 10.0)})
>>> tab
pykx.Table(pykx.q('
x        y
-----------------
77.42128 8.200469
70.49724 9.857311
52.12126 4.629496
99.96985 8.518719
1.196618 9.572477
'))
>>> tab.xbar('x', 10)
pykx.Table(pykx.q('
x  y
-----------
70 8.200469
70 9.857311
50 4.629496
90 8.518719
0  9.572477
'))

table.replace

>>> tab = kx.q('([] a:2 2 3; b:4 2 6; c:(1b;0b;1b); d:(`a;`b;`c); e:(1;2;`a))')
>>> tab
pykx.Table(pykx.q('
a b c d e
----------
2 4 1 a 1
2 2 0 b 2
3 6 1 c `a
'))
>>> tab.replace(2, "test")
pykx.Table(pykx.q('
a     b     c d e
---------------------
`test 4     1 a 1
`test `test 0 b `test
3     6     1 c `a
'))