Skip to content
Styled Pandas dataframe saved as an image that will be viewable when a Jupyter notebook is reloaded.
Jupyter Notebook
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.postBuild
LICENSE
README.md fix typo Jul 15, 2019
apt.txt try getting xvfb to work using xvfb wrapper Jun 17, 2019
index.ipynb link to specific section Sep 18, 2019
requirements.txt update to JupyterLab 1 Nov 11, 2019

README.md

dataframe2img

Binder

Makes images of stylized dataframes so that when Jupyter notebooks are reopened, the stylized view is represented. Importantly, it includes tips that also enable it to be done without generating giant file sizes as well.

Click on a launch binder badge on this page to launch a session where everything needed for this process is set up and the steps in the process are demonstrated.

Pandas dataframe styling is a great feature for visualizing tabular data right in a notebook; however, it is annoying that it gets removed from rendering when you reopen the notebook. (At least every place I have seen so far for apllied cell and text coloring while style.format settings such as style.format("{:.2%}" to show floats as percents with two-decimals, seem to survive. Always to be the case for cell and text coloring?) I wanted a way to have at least the information visible when I reload. So an image would at least be viewable, albeit not as interactive.

STEPS:
Pandas dataframe --> Pandas dataframe with conditional stylized cells ---> Pandas dataframe converted to HTML --> image file --> image viewable when notebook reopened.


Attribution

This builds on the approach from Shovalt here, with some advanced styling following Andy Lane's post.

Addressing the default image size and quality of output was worked out with advice found here (thanks especially to landonwilkins) and here (thanks especially to jarrekk).


Click on a launch binder badge on this page to launch a session where everything needed for this process is set up and the steps are demonstrated.

Binder

You can’t perform that action at this time.