Skip to content

Commit

Permalink
Merge pull request #19 from hablapps/bugfix/kt-preparse-pandas-api
Browse files Browse the repository at this point in the history
Fixes `max`, `min`, `prod` & `sum` for keyed tables
  • Loading branch information
cmccarthy1 authored Jan 19, 2024
2 parents d28e93a + f9903e8 commit 720bb41
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/pykx/pandas_api/pandas_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ def _get_bool_only_subtable(tab):


def preparse_computations(tab, axis=0, skipna=True, numeric_only=False, bool_only=False):
cols = q('cols', tab)
if 'Keyed' in str(type(tab)):
tab = q('{(keys x) _ 0!x}', tab)
tab = tab.values()
cols = tab.columns
if numeric_only:
(tab, cols) = _get_numeric_only_subtable_with_bools(tab)
if bool_only:
Expand Down
9 changes: 9 additions & 0 deletions tests/test_pandas_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1810,6 +1810,15 @@ def test_pandas_max(q):
for i in range(100):
assert float(qmax[i]) == float(pmax[i])

ktab = tab.set_index('sym')
df = ktab.pd()

qmax = ktab.max().py()
pmax = df.max()

assert float(pmax['price']) == qmax['price']
assert float(pmax['ints']) == qmax['ints']


def test_pandas_all(q):
tab = q(
Expand Down

0 comments on commit 720bb41

Please sign in to comment.