From 2aa3a6e60235a670327163f1dad8b88d693f57cb Mon Sep 17 00:00:00 2001 From: chraberturas Date: Thu, 18 Jan 2024 12:05:15 +0100 Subject: [PATCH] QError for mixed lists (suggested by Kx) --- src/pykx/pandas_api/pandas_meta.py | 2 -- tests/test_pandas_api.py | 3 +-- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/pykx/pandas_api/pandas_meta.py b/src/pykx/pandas_api/pandas_meta.py index 1ba34f4..59de3d8 100644 --- a/src/pykx/pandas_api/pandas_meta.py +++ b/src/pykx/pandas_api/pandas_meta.py @@ -260,8 +260,6 @@ 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) - if q("any('[1<>count distinct@;type']')@", res).py(): - raise NotImplementedError("Table contains a column whose type is mixed") filterNan = q('{$[all[10h=type each x]|11h = type x;x;' 'x where not null x]}each') res = filterNan(res) if dropna else res diff --git a/tests/test_pandas_api.py b/tests/test_pandas_api.py index 0c5f893..e6e9891 100644 --- a/tests/test_pandas_api.py +++ b/tests/test_pandas_api.py @@ -2061,6 +2061,5 @@ def test_nunique(kx, q): assert p_m[c] == q_m[c].py() tab = kx.q('([]a:("";" ";"";"foo"))') - with pytest.raises(NotImplementedError, - match=r"Table contains a column whose type is mixed"): + with pytest.raises(kx.QError): raise tab.nunique()