{ "cells": [ { "cell_type": "code", "execution_count": null, "id": "acd1babd", "metadata": {}, "outputs": [], "source": [ "# Imports\n", "\n", "from IPython.display import display, Markdown\n", "from scipy.stats import chi2_contingency\n", "from scipy.stats import t as t_test\n", "import numpy as np\n", "t_value = t_test.isf\n", "\n", "def _display_table(data_array, row_names=None, col_names=None):\n", " _row_num = len(data_array)\n", " _col_num = len(data_array[0])\n", " _rows = []\n", " for i in range(_row_num):\n", " row = f'| {row_names[i]} |'\n", " for j in range(_col_num):\n", " row += f' {data_array[i][j]:.1f} |'\n", " row += f' {sum(data_array[i]):.0f} |'\n", " _rows.append(row)\n", " _total_row = '| **Total** |'\n", " _col_tots = 0\n", " for i in range(_col_num):\n", " col_tot = 0\n", " for j in range(_row_num):\n", " col_tot += data_array[j][i]\n", " _col_tots += col_tot\n", " _total_row += f' **{col_tot:.0f}** |'\n", " _total_row += f' **{_col_tots:.0f}** |'\n", " display(Markdown(\n", " rf\"\"\"\n", "| | {' | '.join(col_names + ['Total'])} |\n", "{'|-'*(len(row_names) + 2)} |\n", "{'\\n'.join(_rows)}\n", "{_total_row}\n", "\"\"\"\n", "))\n", "\n" ] } ], "metadata": { "kernelspec": { "display_name": "base", "language": "python", "name": "python3" }, "language_info": { "name": "python", "version": "3.13.9" } }, "nbformat": 4, "nbformat_minor": 5 }