Files

251 lines
5.5 KiB
Plaintext

{
"cells": [
{
"cell_type": "markdown",
"id": "140b253d-e998-4440-a540-6e30abebb1b5",
"metadata": {},
"source": [
"# Greater Tables Testers\n",
"\n",
"pyarrow stuff...\n",
"\n",
"## Provenance\n",
"* Created new: 2025-06-06"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "f733e11c-9165-4bb8-9dc5-a4ba0c6b556a",
"metadata": {},
"outputs": [],
"source": [
"from greater_tables.core_old import GT\n",
"import greater_tables.utilities as gtu\n",
"import greater_tables.fabrications as gtf\n",
"from pathlib import Path\n",
"import pandas as pd"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "dfa32d92-e4c3-430f-b5be-9f8ab3cb74b5",
"metadata": {},
"outputs": [],
"source": [
"# make some random dataframes\n",
"fab = gtf.Fabricator(pyarrow=True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "aa6fd1eb-1a20-4400-845f-8aa7567ad25e",
"metadata": {},
"outputs": [],
"source": [
"for _ in range(10):\n",
" display(GT(fab.random().head(10))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "46147a8a-5c8a-47ad-a5af-36733fadf64b",
"metadata": {},
"outputs": [],
"source": [
"dfs = dict(zip('ABCDE', [fab.random().head(10) for _ in range(5)]))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5ae6e5af-ee7d-4917-851e-2174c772ea6d",
"metadata": {},
"outputs": [],
"source": [
"p = Path('\\\\s\\\\appdata\\\\archivum\\\\libraries\\\\silly-library')\n",
"ps = list(p.glob('*.feather'))\n",
"ps"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "bdb7f70c-e90a-45db-b26b-93a624d7ef2c",
"metadata": {},
"outputs": [],
"source": [
"dfs = {f.name: pd.read_feather(f, dtype_backend='pyarrow') for f in ps}"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "547176b4-ad8d-419a-baa9-caa725e746a5",
"metadata": {},
"outputs": [],
"source": [
"for v in dfs.values(): print(v.dtypes)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1224b554-c80e-4ca4-a34a-b51bdf41ec07",
"metadata": {},
"outputs": [],
"source": [
"for k, v in dfs.items():\n",
" display(GT(v.head(20), caption=k, show_index=False))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "01f627b5-22b9-45d1-9833-0afdc497fd7e",
"metadata": {},
"outputs": [],
"source": [
"dfm = gtt.make_manual_tests()\n",
"for d in dfm:\n",
" display(GT(d))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "86032085-3794-4af9-bfd8-5357af200196",
"metadata": {},
"outputs": [],
"source": [
"df = gtt.make_test_dataframe(8, 5)\n",
"f = GT(df, max_table_width=50)\n",
"f"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1f4ae417-7ed0-45f7-9da4-79ec3667f96a",
"metadata": {},
"outputs": [],
"source": [
"f = GT(df, max_table_width=40)\n",
"print(f._repr_latex_())"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "8a32a477-dd08-4f42-92e1-63c91557907d",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"id": "871ef69a-6cc6-4f3f-a766-8a4cf4291c85",
"metadata": {},
"source": [
"# HTML"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "dc15f2fe-58e9-4618-9dcf-ab9dcdfa3302",
"metadata": {},
"outputs": [],
"source": [
"for k, v in ts.items():\n",
" display(GT(v.head(), show_index=True, max_table_width=80, debug=False, caption=k))"
]
},
{
"cell_type": "markdown",
"id": "945f2bb9-9295-498a-a724-f367ce742533",
"metadata": {},
"source": [
"# LaTeX Mode"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "51858d09-c98f-4675-a61c-c7a839f75686",
"metadata": {},
"outputs": [],
"source": [
"for k, v in ts.items():\n",
" print(GT(v.head(), show_index=True, max_table_width=80, debug=False, caption=k).make_tikz())"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "fa56eb4d-7b08-4225-9a64-c465905e87b9",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"id": "125b0cff-f248-4864-90e6-d8bdf84b603c",
"metadata": {},
"source": [
"# Text Mode"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5a9dda81-8334-4f9f-ab2c-358228c4d936",
"metadata": {},
"outputs": [],
"source": [
"for k, v in ts.items():\n",
" # if k != 'multiindex': continue\n",
" cw_target = 80\n",
" input_target = cw_target - 4 * v.shape[1]\n",
" print(f'{cw_target = } and {input_target = }')\n",
" f = (GT(v.head(), show_index=True, max_table_width=80 - 4 * v.shape[1], debug=True))\n",
" sc.analysis(f)\n",
" # break\n",
" print('=*'*80)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "dc2dc152-16fc-4782-896f-3b92ceddc5bb",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.13.3"
}
},
"nbformat": 4,
"nbformat_minor": 5
}