Skip to content

Commit

Permalink
Patch nunique function
Browse files Browse the repository at this point in the history
  • Loading branch information
FRANCISCO TÓRTOLA VIVO committed Mar 8, 2024
1 parent d70b430 commit 5dd91c4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
5 changes: 1 addition & 4 deletions src/pykx/pandas_api/pandas_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,10 +292,7 @@ def sum(self, axis=0, skipna=True, numeric_only=False, min_count=0):

@convert_result
def nunique(self, axis=0, dropna=True):
res, cols = preparse_computations(self, axis, skipna=False)
filternan = q('{$[all[10h=type each x]|11h = type x;x;'
'x where not null x]}each')
res = filternan(res) if dropna else res
res, cols = preparse_computations(self, axis, skipna=dropna)
return (q("('[count;distinct]')", res), cols)

def agg(self, func, axis=0, *args, **kwargs): # noqa: C901
Expand Down
2 changes: 1 addition & 1 deletion tests/test_pandas_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2110,7 +2110,7 @@ def test_keyed_loc_fixes(q):


def test_nunique(kx, q):
tab = kx.q('([]a:4 0n 7 6;b:4 0n 0n 7;c:``foo`foo`)')
tab = kx.q('([]a:4 0n 7 6;b:4 0n 0n 7;c:4.1 2.0 3.1 2.0)')
df = tab.pd()
p_m = df.nunique()
q_m = tab.nunique()
Expand Down

0 comments on commit 5dd91c4

Please sign in to comment.