diff --git a/docs/user-guide/advanced/Pandas_API.ipynb b/docs/user-guide/advanced/Pandas_API.ipynb index 239c4c8..3b867d6 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 | The values of the table as a matrix. |" + ] + }, + { + "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 39668d5..6e80339 100644 --- a/src/pykx/pandas_api/pandas_meta.py +++ b/src/pykx/pandas_api/pandas_meta.py @@ -135,6 +135,10 @@ def shape(self): def size(self): return q('{count[x] * count[cols x]}', self) + @property + def values(self): + return q('value each', self) + @api_return def mean(self, axis: int = 0, numeric_only: bool = False): tab = self diff --git a/tests/test_pandas_api.py b/tests/test_pandas_api.py index acfe55f..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)'))