{ "cells": [ { "cell_type": "markdown", "id": "68c5f610", "metadata": {}, "source": [ "(content:code-outputs)=\n", "\n", "# Formatting code outputs\n", "\n", "The formatting of code outputs is highly configurable.\n", "Below we give examples of how to format particular outputs and even insert outputs into other locations of the document.\n", "\n", "The [MyST cheat sheet](myst_cheatsheet) provides a [list of `code-cell` tags available](myst_cheatsheet:code-cell:tags)\n", "\n", ":::{seealso}\n", "The [MyST-NB documentation](myst-nb:use/format/cutomise), for how to fully customize the output renderer.\n", ":::\n", "\n", "(content:code-outputs:library-outputs)=\n", "## Library output formatting\n", "\n", "Many libraries support their own HTML output formatting, and this generally carries over to Jupyter Book outputs as well.\n", "\n", "For example, the following cell uses Pandas to format cells based on their values:" ] }, { "cell_type": "code", "execution_count": 1, "id": "d751fb94", "metadata": { "tags": [ "hide-input" ] }, "outputs": [ { "data": { "text/html": [ "\n", "
\n", " | A | \n", "B | \n", "C | \n", "D | \n", "E | \n", "
---|---|---|---|---|---|
0 | \n", "1.000000 | \n", "1.329212 | \n", "nan | \n", "-0.316280 | \n", "-0.990810 | \n", "
1 | \n", "2.000000 | \n", "-1.070816 | \n", "-1.438713 | \n", "0.564417 | \n", "0.295722 | \n", "
2 | \n", "3.000000 | \n", "-1.626404 | \n", "0.219565 | \n", "0.678805 | \n", "1.889273 | \n", "
3 | \n", "4.000000 | \n", "0.961538 | \n", "0.104011 | \n", "nan | \n", "0.850229 | \n", "
4 | \n", "5.000000 | \n", "1.453425 | \n", "1.057737 | \n", "0.165562 | \n", "0.515018 | \n", "
5 | \n", "6.000000 | \n", "-1.336936 | \n", "0.562861 | \n", "1.392855 | \n", "-0.063328 | \n", "
6 | \n", "7.000000 | \n", "0.121668 | \n", "1.207603 | \n", "-0.002040 | \n", "1.627796 | \n", "
7 | \n", "8.000000 | \n", "0.354493 | \n", "1.037528 | \n", "-0.385684 | \n", "0.519818 | \n", "
8 | \n", "9.000000 | \n", "1.686583 | \n", "-1.325963 | \n", "1.428984 | \n", "-2.089354 | \n", "
9 | \n", "10.000000 | \n", "-0.129820 | \n", "0.631523 | \n", "-0.586538 | \n", "0.290720 | \n", "