From 82d276d5adb7e1a61b376baa47f5d4321e1f7843 Mon Sep 17 00:00:00 2001 From: cperezln Date: Thu, 21 Dec 2023 09:41:16 +0100 Subject: [PATCH 01/11] Values first approach --- src/pykx/pandas_api/pandas_meta.py | 5 +++++ tests/test_pandas_api.py | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/src/pykx/pandas_api/pandas_meta.py b/src/pykx/pandas_api/pandas_meta.py index 39668d5..2754fa9 100644 --- a/src/pykx/pandas_api/pandas_meta.py +++ b/src/pykx/pandas_api/pandas_meta.py @@ -257,6 +257,11 @@ def sum(self, axis=0, skipna=True, numeric_only=False, min_count=0): min_count ), cols) + @api_return + def values(self, skipna = True, numeric_only = False): + tab = self + return q('{[table] flip value flip table}', tab) + def agg(self, func, axis=0, *args, **kwargs): # noqa: C901 if 'KeyedTable' in str(type(self)): raise NotImplementedError("'agg' method not presently supported for KeyedTable") diff --git a/tests/test_pandas_api.py b/tests/test_pandas_api.py index acfe55f..d2a6f91 100644 --- a/tests/test_pandas_api.py +++ b/tests/test_pandas_api.py @@ -2029,3 +2029,11 @@ def test_keyed_loc_fixes(q): mkt[['k1', 'y']] with pytest.raises(KeyError): mkt['k1'] + +def test_values(q): + col1 = q('10?100') + col2 = q('10?`a`b`c`d') + col3 = q('10?`x`y`z`1`2`3') + matrix = q('{[r1; r2; r3] flip enlist[r1; r2; r3]}', col1, col2, col3) + tab = q('{[price; sym; id] ([]p: price; s: sym; i: id)}', col1, col2, col3) + assert tab.values().py() == matrix.py() From 731d464aa34d2c43d9d84b8b949ed3fa55137997 Mon Sep 17 00:00:00 2001 From: cperezln Date: Thu, 21 Dec 2023 15:22:40 +0100 Subject: [PATCH 02/11] Test changed to check pd.values against implemented values. Values optimized (to value peach) --- src/pykx/pandas_api/pandas_meta.py | 2 +- tests/test_pandas_api.py | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/pykx/pandas_api/pandas_meta.py b/src/pykx/pandas_api/pandas_meta.py index 2754fa9..8a8cdad 100644 --- a/src/pykx/pandas_api/pandas_meta.py +++ b/src/pykx/pandas_api/pandas_meta.py @@ -260,7 +260,7 @@ def sum(self, axis=0, skipna=True, numeric_only=False, min_count=0): @api_return def values(self, skipna = True, numeric_only = False): tab = self - return q('{[table] flip value flip table}', tab) + return q('value peach', tab) def agg(self, func, axis=0, *args, **kwargs): # noqa: C901 if 'KeyedTable' in str(type(self)): diff --git a/tests/test_pandas_api.py b/tests/test_pandas_api.py index d2a6f91..3ab3025 100644 --- a/tests/test_pandas_api.py +++ b/tests/test_pandas_api.py @@ -2034,6 +2034,8 @@ def test_values(q): col1 = q('10?100') col2 = q('10?`a`b`c`d') col3 = q('10?`x`y`z`1`2`3') - matrix = q('{[r1; r2; r3] flip enlist[r1; r2; r3]}', col1, col2, col3) tab = q('{[price; sym; id] ([]p: price; s: sym; i: id)}', col1, col2, col3) - assert tab.values().py() == matrix.py() + q_table = tab + pandas_table = tab.pd() + lol = np.array(q_table.values()) + assert pandas_table.values == np.array(q_table.values().py()) From db79521dfb97aed1be8e204ea4fd9f7da9bcd913 Mon Sep 17 00:00:00 2001 From: cperezln Date: Thu, 21 Dec 2023 15:59:26 +0100 Subject: [PATCH 03/11] Changed to property (as defined in pandas docs). documentation written --- docs/user-guide/advanced/Pandas_API.ipynb | 67 ++++++++++++++++------- src/pykx/pandas_api/pandas_meta.py | 11 ++-- 2 files changed, 53 insertions(+), 25 deletions(-) diff --git a/docs/user-guide/advanced/Pandas_API.ipynb b/docs/user-guide/advanced/Pandas_API.ipynb index 239c4c8..d4dd587 100644 --- a/docs/user-guide/advanced/Pandas_API.ipynb +++ b/docs/user-guide/advanced/Pandas_API.ipynb @@ -345,14 +345,51 @@ "cell_type": "code", "execution_count": null, "id": "c77c5bc7", - "metadata": { - "scrolled": false - }, + "metadata": {}, "outputs": [], "source": [ "tab.size" ] }, + { + "cell_type": "markdown", + "id": "4023811f-0f23-4e4b-919c-c055b865d9d2", + "metadata": {}, + "source": [ + "### Table.values\n", + "Return a matricial representation of the DataFrame.\n", + "\n", + "Only the values in the DataFrame will be returned, the axes labels will be removed.\n", + "\n", + "**Returns:**\n", + "\n", + "| Type | Description |\n", + "| :---------------: | :------------------------------------------------------------------- |\n", + "| List | Rows of the table, each as a list. |" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "a7843813-43fc-4920-acd9-6fd2dd50c32e", + "metadata": {}, + "outputs": [ + { + "ename": "NameError", + "evalue": "name 'tab' is not defined", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m/tmp/ipykernel_77428/394326152.py\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mtab\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mvalues\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[0;31mNameError\u001b[0m: name 'tab' is not defined" + ] + } + ], + "source": [ + "tab.values" + ] + }, { "cell_type": "markdown", "id": "2be2ece3", @@ -513,9 +550,7 @@ "cell_type": "code", "execution_count": null, "id": "5664bd93", - "metadata": { - "scrolled": false - }, + "metadata": {}, "outputs": [], "source": [ "tab.median(axis=1)" @@ -601,9 +636,7 @@ "cell_type": "code", "execution_count": null, "id": "130081ce", - "metadata": { - "scrolled": false - }, + "metadata": {}, "outputs": [], "source": [ "tab.mode(axis=1)" @@ -707,9 +740,7 @@ "cell_type": "code", "execution_count": null, "id": "916fcf4d", - "metadata": { - "scrolled": false - }, + "metadata": {}, "outputs": [], "source": [ "tab.head()" @@ -904,7 +935,7 @@ }, { "cell_type": "markdown", - "id": "9e831e14", + "id": "be00451c-d3e8-48d3-a981-e51639650d31", "metadata": {}, "source": [ "### Table.at[]\n", @@ -1167,9 +1198,7 @@ "cell_type": "code", "execution_count": null, "id": "a13730fd", - "metadata": { - "scrolled": false - }, + "metadata": {}, "outputs": [], "source": [ "tab.iloc[:5]" @@ -1296,9 +1325,7 @@ "cell_type": "code", "execution_count": null, "id": "a46189b2", - "metadata": { - "scrolled": false - }, + "metadata": {}, "outputs": [], "source": [ "display(tab.head())\n", @@ -3032,7 +3059,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.3" + "version": "3.10.12" } }, "nbformat": 4, diff --git a/src/pykx/pandas_api/pandas_meta.py b/src/pykx/pandas_api/pandas_meta.py index 8a8cdad..4a483f4 100644 --- a/src/pykx/pandas_api/pandas_meta.py +++ b/src/pykx/pandas_api/pandas_meta.py @@ -134,7 +134,12 @@ def shape(self): @property def size(self): return q('{count[x] * count[cols x]}', self) - + + @property + def values(self): + tab = self + return q('value peach', tab) + @api_return def mean(self, axis: int = 0, numeric_only: bool = False): tab = self @@ -257,10 +262,6 @@ def sum(self, axis=0, skipna=True, numeric_only=False, min_count=0): min_count ), cols) - @api_return - def values(self, skipna = True, numeric_only = False): - tab = self - return q('value peach', tab) def agg(self, func, axis=0, *args, **kwargs): # noqa: C901 if 'KeyedTable' in str(type(self)): From 213f65e17448154242fc35e4431edbfa29009cfc Mon Sep 17 00:00:00 2001 From: cperezln Date: Thu, 21 Dec 2023 16:00:22 +0100 Subject: [PATCH 04/11] Changed values to property (as defined in pandas docs). values documentation written --- src/pykx/pandas_api/pandas_meta.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pykx/pandas_api/pandas_meta.py b/src/pykx/pandas_api/pandas_meta.py index 4a483f4..3e018d9 100644 --- a/src/pykx/pandas_api/pandas_meta.py +++ b/src/pykx/pandas_api/pandas_meta.py @@ -139,7 +139,7 @@ def size(self): def values(self): tab = self return q('value peach', tab) - + @api_return def mean(self, axis: int = 0, numeric_only: bool = False): tab = self From 7b151668a9f6959214da50aa225ccf3e2bac8325 Mon Sep 17 00:00:00 2001 From: cperezln Date: Fri, 22 Dec 2023 14:00:37 +0100 Subject: [PATCH 05/11] Undone Notebook metadata changes --- docs/user-guide/advanced/Pandas_API.ipynb | 28 ++++++++++++++++------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/docs/user-guide/advanced/Pandas_API.ipynb b/docs/user-guide/advanced/Pandas_API.ipynb index d4dd587..9c9c67b 100644 --- a/docs/user-guide/advanced/Pandas_API.ipynb +++ b/docs/user-guide/advanced/Pandas_API.ipynb @@ -345,7 +345,9 @@ "cell_type": "code", "execution_count": null, "id": "c77c5bc7", - "metadata": {}, + "metadata": { + "scrolled": false + }, "outputs": [], "source": [ "tab.size" @@ -550,7 +552,9 @@ "cell_type": "code", "execution_count": null, "id": "5664bd93", - "metadata": {}, + "metadata": { + "scrolled": false + }, "outputs": [], "source": [ "tab.median(axis=1)" @@ -636,7 +640,9 @@ "cell_type": "code", "execution_count": null, "id": "130081ce", - "metadata": {}, + "metadata": { + "scrolled": false + }, "outputs": [], "source": [ "tab.mode(axis=1)" @@ -740,7 +746,9 @@ "cell_type": "code", "execution_count": null, "id": "916fcf4d", - "metadata": {}, + "metadata": { + "scrolled": false + }, "outputs": [], "source": [ "tab.head()" @@ -935,7 +943,7 @@ }, { "cell_type": "markdown", - "id": "be00451c-d3e8-48d3-a981-e51639650d31", + "id": "9e831e14", "metadata": {}, "source": [ "### Table.at[]\n", @@ -1198,7 +1206,9 @@ "cell_type": "code", "execution_count": null, "id": "a13730fd", - "metadata": {}, + "metadata": { + "scrolled": false + }, "outputs": [], "source": [ "tab.iloc[:5]" @@ -1316,7 +1326,9 @@ { "cell_type": "markdown", "id": "35062560", - "metadata": {}, + "metadata": { + "scrolled": false + }, "source": [ "Remove the `z` and `w` columns from the table and return them." ] @@ -3059,7 +3071,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.12" + "version": "3.8.3" } }, "nbformat": 4, From f85418ab007f6fd447e20919630b62536c2a2190 Mon Sep 17 00:00:00 2001 From: cperezln Date: Fri, 12 Jan 2024 16:26:33 +0100 Subject: [PATCH 06/11] Minor changes in docs. Tests cover string case --- docs/user-guide/advanced/Pandas_API.ipynb | 21 ++++----------------- src/pykx/pandas_api/pandas_meta.py | 1 - tests/test_pandas_api.py | 5 ++--- 3 files changed, 6 insertions(+), 21 deletions(-) diff --git a/docs/user-guide/advanced/Pandas_API.ipynb b/docs/user-guide/advanced/Pandas_API.ipynb index 9c9c67b..1b07548 100644 --- a/docs/user-guide/advanced/Pandas_API.ipynb +++ b/docs/user-guide/advanced/Pandas_API.ipynb @@ -375,19 +375,6 @@ "execution_count": 2, "id": "a7843813-43fc-4920-acd9-6fd2dd50c32e", "metadata": {}, - "outputs": [ - { - "ename": "NameError", - "evalue": "name 'tab' is not defined", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", - "\u001b[0;32m/tmp/ipykernel_77428/394326152.py\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mtab\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mvalues\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", - "\u001b[0;31mNameError\u001b[0m: name 'tab' is not defined" - ] - } - ], "source": [ "tab.values" ] @@ -1326,9 +1313,7 @@ { "cell_type": "markdown", "id": "35062560", - "metadata": { - "scrolled": false - }, + "metadata": {}, "source": [ "Remove the `z` and `w` columns from the table and return them." ] @@ -1337,7 +1322,9 @@ "cell_type": "code", "execution_count": null, "id": "a46189b2", - "metadata": {}, + "metadata": { + "scrolled": false + }, "outputs": [], "source": [ "display(tab.head())\n", diff --git a/src/pykx/pandas_api/pandas_meta.py b/src/pykx/pandas_api/pandas_meta.py index 3e018d9..bbd039d 100644 --- a/src/pykx/pandas_api/pandas_meta.py +++ b/src/pykx/pandas_api/pandas_meta.py @@ -262,7 +262,6 @@ def sum(self, axis=0, skipna=True, numeric_only=False, min_count=0): min_count ), cols) - def agg(self, func, axis=0, *args, **kwargs): # noqa: C901 if 'KeyedTable' in str(type(self)): raise NotImplementedError("'agg' method not presently supported for KeyedTable") diff --git a/tests/test_pandas_api.py b/tests/test_pandas_api.py index 3ab3025..ac19d10 100644 --- a/tests/test_pandas_api.py +++ b/tests/test_pandas_api.py @@ -2034,8 +2034,7 @@ def test_values(q): col1 = q('10?100') col2 = q('10?`a`b`c`d') col3 = q('10?`x`y`z`1`2`3') - tab = q('{[price; sym; id] ([]p: price; s: sym; i: id)}', col1, col2, col3) + tab = q('{[price; sym; id] ([]p: price; s: sym; i: string id)}', col1, col2, col3) q_table = tab pandas_table = tab.pd() - lol = np.array(q_table.values()) - assert pandas_table.values == np.array(q_table.values().py()) + assert pandas_table.values.tolist() == q_table.values.py() From 9949f555430d044bf191eb82dd8d54bccbfc26a3 Mon Sep 17 00:00:00 2001 From: cperezln Date: Mon, 15 Jan 2024 15:52:52 +0100 Subject: [PATCH 07/11] Added implementation of values --- docs/user-guide/advanced/Pandas_API.ipynb | 26 +++++++++++++++++++++++ src/pykx/pandas_api/pandas_meta.py | 10 ++++----- tests/test_pandas_api.py | 7 +++--- 3 files changed, 35 insertions(+), 8 deletions(-) diff --git a/docs/user-guide/advanced/Pandas_API.ipynb b/docs/user-guide/advanced/Pandas_API.ipynb index 239c4c8..1b07548 100644 --- a/docs/user-guide/advanced/Pandas_API.ipynb +++ b/docs/user-guide/advanced/Pandas_API.ipynb @@ -353,6 +353,32 @@ "tab.size" ] }, + { + "cell_type": "markdown", + "id": "4023811f-0f23-4e4b-919c-c055b865d9d2", + "metadata": {}, + "source": [ + "### Table.values\n", + "Return a matricial representation of the DataFrame.\n", + "\n", + "Only the values in the DataFrame will be returned, the axes labels will be removed.\n", + "\n", + "**Returns:**\n", + "\n", + "| Type | Description |\n", + "| :---------------: | :------------------------------------------------------------------- |\n", + "| List | Rows of the table, each as a list. |" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "a7843813-43fc-4920-acd9-6fd2dd50c32e", + "metadata": {}, + "source": [ + "tab.values" + ] + }, { "cell_type": "markdown", "id": "2be2ece3", diff --git a/src/pykx/pandas_api/pandas_meta.py b/src/pykx/pandas_api/pandas_meta.py index 2754fa9..bbd039d 100644 --- a/src/pykx/pandas_api/pandas_meta.py +++ b/src/pykx/pandas_api/pandas_meta.py @@ -134,6 +134,11 @@ def shape(self): @property def size(self): return q('{count[x] * count[cols x]}', self) + + @property + def values(self): + tab = self + return q('value peach', tab) @api_return def mean(self, axis: int = 0, numeric_only: bool = False): @@ -257,11 +262,6 @@ def sum(self, axis=0, skipna=True, numeric_only=False, min_count=0): min_count ), cols) - @api_return - def values(self, skipna = True, numeric_only = False): - tab = self - return q('{[table] flip value flip table}', tab) - def agg(self, func, axis=0, *args, **kwargs): # noqa: C901 if 'KeyedTable' in str(type(self)): raise NotImplementedError("'agg' method not presently supported for KeyedTable") diff --git a/tests/test_pandas_api.py b/tests/test_pandas_api.py index d2a6f91..ac19d10 100644 --- a/tests/test_pandas_api.py +++ b/tests/test_pandas_api.py @@ -2034,6 +2034,7 @@ def test_values(q): col1 = q('10?100') col2 = q('10?`a`b`c`d') col3 = q('10?`x`y`z`1`2`3') - matrix = q('{[r1; r2; r3] flip enlist[r1; r2; r3]}', col1, col2, col3) - tab = q('{[price; sym; id] ([]p: price; s: sym; i: id)}', col1, col2, col3) - assert tab.values().py() == matrix.py() + tab = q('{[price; sym; id] ([]p: price; s: sym; i: string id)}', col1, col2, col3) + q_table = tab + pandas_table = tab.pd() + assert pandas_table.values.tolist() == q_table.values.py() From c7e3ce9aeb48f4cf75819268a8050c9fb76ab9d4 Mon Sep 17 00:00:00 2001 From: cperezln Date: Wed, 17 Jan 2024 16:46:24 +0100 Subject: [PATCH 08/11] Some minor corrections proposed by reviewers --- docs/user-guide/advanced/Pandas_API.ipynb | 2 +- src/pykx/pandas_api/pandas_meta.py | 5 ++--- tests/test_pandas_api.py | 18 +++++++++--------- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/docs/user-guide/advanced/Pandas_API.ipynb b/docs/user-guide/advanced/Pandas_API.ipynb index 1b07548..3b867d6 100644 --- a/docs/user-guide/advanced/Pandas_API.ipynb +++ b/docs/user-guide/advanced/Pandas_API.ipynb @@ -367,7 +367,7 @@ "\n", "| Type | Description |\n", "| :---------------: | :------------------------------------------------------------------- |\n", - "| List | Rows of the table, each as a list. |" + "| List | The values of the table as a matrix. |" ] }, { diff --git a/src/pykx/pandas_api/pandas_meta.py b/src/pykx/pandas_api/pandas_meta.py index bbd039d..6e80339 100644 --- a/src/pykx/pandas_api/pandas_meta.py +++ b/src/pykx/pandas_api/pandas_meta.py @@ -134,11 +134,10 @@ def shape(self): @property def size(self): return q('{count[x] * count[cols x]}', self) - + @property def values(self): - tab = self - return q('value peach', tab) + return q('value each', self) @api_return def mean(self, axis: int = 0, numeric_only: bool = False): diff --git a/tests/test_pandas_api.py b/tests/test_pandas_api.py index ac19d10..02befe2 100644 --- a/tests/test_pandas_api.py +++ b/tests/test_pandas_api.py @@ -59,6 +59,15 @@ def test_df_size(q): assert (df.size == df.pd().size) +def test_df_values(q): + tab = q('([]p: 10?100; s: 10?`a`b`c`d; id: 10?"abc123; nulls: 10?0n")') + pandas_table = tab.pd() + assert pandas_table.values.tolist() == tab.values.py() + tab = q('([]p: 2?100; n: (::; ::))') + pandas_table = tab.pd() + assert pandas_table.values.tolist() == tab.values.py() + + def test_df_head(kx, q): df = q('([] til 10; 10 - til 10)') assert check_result_and_type(kx, df.head(), q('5 # ([] til 10; 10 - til 10)')) @@ -2029,12 +2038,3 @@ def test_keyed_loc_fixes(q): mkt[['k1', 'y']] with pytest.raises(KeyError): mkt['k1'] - -def test_values(q): - col1 = q('10?100') - col2 = q('10?`a`b`c`d') - col3 = q('10?`x`y`z`1`2`3') - tab = q('{[price; sym; id] ([]p: price; s: sym; i: string id)}', col1, col2, col3) - q_table = tab - pandas_table = tab.pd() - assert pandas_table.values.tolist() == q_table.values.py() From 267111f247b885bc7c11a6219684dceb95be439c Mon Sep 17 00:00:00 2001 From: cperezln Date: Thu, 18 Jan 2024 08:49:46 +0100 Subject: [PATCH 09/11] Removed blank spaces. Improved tests. Merged solved --- docs/user-guide/advanced/Pandas_API.ipynb | 20 -------------------- src/pykx/pandas_api/pandas_meta.py | 4 ---- tests/test_pandas_api.py | 13 ------------- 3 files changed, 37 deletions(-) diff --git a/docs/user-guide/advanced/Pandas_API.ipynb b/docs/user-guide/advanced/Pandas_API.ipynb index a1a940e..5d72b82 100644 --- a/docs/user-guide/advanced/Pandas_API.ipynb +++ b/docs/user-guide/advanced/Pandas_API.ipynb @@ -367,11 +367,7 @@ "\n", "| Type | Description |\n", "| :---------------: | :------------------------------------------------------------------- |\n", -<<<<<<< HEAD "| List | The values of the table as a matrix. |" -======= - "| List | Rows of the table, each as a list. |" ->>>>>>> 7b151668a9f6959214da50aa225ccf3e2bac8325 ] }, { @@ -379,22 +375,6 @@ "execution_count": 2, "id": "a7843813-43fc-4920-acd9-6fd2dd50c32e", "metadata": {}, -<<<<<<< HEAD -======= - "outputs": [ - { - "ename": "NameError", - "evalue": "name 'tab' is not defined", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", - "\u001b[0;32m/tmp/ipykernel_77428/394326152.py\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mtab\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mvalues\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", - "\u001b[0;31mNameError\u001b[0m: name 'tab' is not defined" - ] - } - ], ->>>>>>> 7b151668a9f6959214da50aa225ccf3e2bac8325 "source": [ "tab.values" ] diff --git a/src/pykx/pandas_api/pandas_meta.py b/src/pykx/pandas_api/pandas_meta.py index 73adeb8..d973ce6 100644 --- a/src/pykx/pandas_api/pandas_meta.py +++ b/src/pykx/pandas_api/pandas_meta.py @@ -266,10 +266,6 @@ def sum(self, axis=0, skipna=True, numeric_only=False, min_count=0): min_count ), cols) -<<<<<<< HEAD -======= - ->>>>>>> 7b151668a9f6959214da50aa225ccf3e2bac8325 def agg(self, func, axis=0, *args, **kwargs): # noqa: C901 if 'KeyedTable' in str(type(self)): raise NotImplementedError("'agg' method not presently supported for KeyedTable") diff --git a/tests/test_pandas_api.py b/tests/test_pandas_api.py index 8a671bf..02befe2 100644 --- a/tests/test_pandas_api.py +++ b/tests/test_pandas_api.py @@ -2038,16 +2038,3 @@ def test_keyed_loc_fixes(q): mkt[['k1', 'y']] with pytest.raises(KeyError): mkt['k1'] -<<<<<<< HEAD -======= - -def test_values(q): - col1 = q('10?100') - col2 = q('10?`a`b`c`d') - col3 = q('10?`x`y`z`1`2`3') - tab = q('{[price; sym; id] ([]p: price; s: sym; i: id)}', col1, col2, col3) - q_table = tab - pandas_table = tab.pd() - lol = np.array(q_table.values()) - assert pandas_table.values == np.array(q_table.values().py()) ->>>>>>> 7b151668a9f6959214da50aa225ccf3e2bac8325 From 01dced7bdb44d8da4696be851b85987316492850 Mon Sep 17 00:00:00 2001 From: cperezln Date: Thu, 18 Jan 2024 08:54:08 +0100 Subject: [PATCH 10/11] Corrected .ipynb --- docs/user-guide/advanced/Pandas_API.ipynb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/user-guide/advanced/Pandas_API.ipynb b/docs/user-guide/advanced/Pandas_API.ipynb index 5d72b82..3b867d6 100644 --- a/docs/user-guide/advanced/Pandas_API.ipynb +++ b/docs/user-guide/advanced/Pandas_API.ipynb @@ -1313,9 +1313,7 @@ { "cell_type": "markdown", "id": "35062560", - "metadata": { - "scrolled": false - }, + "metadata": {}, "source": [ "Remove the `z` and `w` columns from the table and return them." ] @@ -1324,7 +1322,9 @@ "cell_type": "code", "execution_count": null, "id": "a46189b2", - "metadata": {}, + "metadata": { + "scrolled": false + }, "outputs": [], "source": [ "display(tab.head())\n", From 631159daea296f20862fe93cd8f079c2c3daf693 Mon Sep 17 00:00:00 2001 From: cperezln Date: Thu, 18 Jan 2024 09:49:37 +0100 Subject: [PATCH 11/11] Linting errors solved --- src/pykx/pandas_api/pandas_meta.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pykx/pandas_api/pandas_meta.py b/src/pykx/pandas_api/pandas_meta.py index c7b1158..6e80339 100644 --- a/src/pykx/pandas_api/pandas_meta.py +++ b/src/pykx/pandas_api/pandas_meta.py @@ -134,7 +134,7 @@ def shape(self): @property def size(self): return q('{count[x] * count[cols x]}', self) - + @property def values(self): return q('value each', self)