diff --git a/src/pykx/pandas_api/pandas_meta.py b/src/pykx/pandas_api/pandas_meta.py index 0b6858b..069d1ef 100644 --- a/src/pykx/pandas_api/pandas_meta.py +++ b/src/pykx/pandas_api/pandas_meta.py @@ -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 diff --git a/tests/test_pandas_api.py b/tests/test_pandas_api.py index 38560a9..37173c6 100644 --- a/tests/test_pandas_api.py +++ b/tests/test_pandas_api.py @@ -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()