{ "cells": [ { "cell_type": "markdown", "id": "588161fa", "metadata": {}, "source": [ "# Show Index\n", "\n", "By default, the index of a Series/DataFrame is shown only when not trivial, i.e. when it has a name, or when it differs from a range index. If you prefer, you can change the value of `showIndex` to either `True` or `False` to always or never show the index (the default value being `\"auto\"`)." ] }, { "cell_type": "code", "execution_count": 1, "id": "554df4c7", "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "\n", "
\n", "\n", "\n", "
\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "import pandas as pd\n", "\n", "import itables\n", "\n", "itables.init_notebook_mode()" ] }, { "cell_type": "markdown", "id": "842c18f5", "metadata": {}, "source": [ "You can change this behavior globally with e.g.\n", "```python\n", "itables.options.showIndex = True\n", "```\n", "\n", "or locally by passing an argument `showIndex` to the `show` function:" ] }, { "cell_type": "code", "execution_count": 2, "id": "6e303e63", "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", " \n", "
\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", " \n", " \n", " \n", " \n", "\n", " \n", " \n", " \n", " \n", "\n", " \n", " \n", " \n", " \n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", "\n", " Loading ITables v2.4.0rc1 from the init_notebook_mode cell...\n", " (need help?)
\n", "\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "df_with_range_index = pd.DataFrame({\"letter\": list(\"abcd\")})\n", "itables.show(df_with_range_index, showIndex=True)" ] } ], "metadata": { "jupytext": { "formats": "md:myst", "notebook_metadata_filter": "-jupytext.text_representation.jupytext_version", "text_representation": { "extension": ".md", "format_name": "myst", "format_version": 0.13 } }, "kernelspec": { "display_name": "itables", "language": "python", "name": "itables" }, "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.11.12" }, "source_map": [ 13, 19, 25, 34 ] }, "nbformat": 4, "nbformat_minor": 5 }