Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes max, min, prod & sum for keyed tables #19

Merged
merged 3 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion 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)
neutropolis marked this conversation as resolved.
Show resolved Hide resolved
cols = q('cols', tab)
neutropolis marked this conversation as resolved.
Show resolved Hide resolved
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 = q('{1!x}', tab)
neutropolis marked this conversation as resolved.
Show resolved Hide resolved
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