I have a small-shaped (5 rows, 3 columns) dataframe which I can display by calling df
in jupyter cell. I would like to enlarge (font size) this output for presentation purpose. Is it possible?
In order to change the default HTML style for all dataframes in a notebook and not having to apply the style individually to each dataframe, you have two options:
For a single notebook use the magic function %%html
:
In the first cell of your notebook put
%%html
<style>
/* Any CSS style can go in here. */
.dataframe th {
font-size: 18px;
}
.dataframe td {
font-size: 16px;
}
</style>
For all notebooks adjust the Jupyter CSS style:
Add the CSS style information
.dataframe th {
font-size: 18px;
}
.dataframe td {
font-size: 16px;
}
to one of the following files:
Jupyter Notebook:
$HOME/.jupyter/custom/custom.css
JupyterLab (depending on the theme):
$HOME/anaconda3/envs/[ENVIRONMENT NAME]/share/jupyter/lab/themes/@jupyterlab/theme-dark-extension/index.css
or
$HOME/anaconda3/envs/[ENVIRONMENT NAME]/share/jupyter/lab/themes/@jupyterlab/theme-light-extension/index.css
For the JupyterLab the custom.css is unfortunateley not used, so I do not see another way to change the CSS.
You can play around with styles using df.style.set_table_styles()
This might help:
heading_properties = [('font-size', '18px')]
cell_properties = [('font-size', '16px')]
dfstyle = [dict(selector="th", props=heading_properties),\
dict(selector="td", props=cell_properties)]
df.style.set_table_styles(dfstyle)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With