Skip to main content

Embed pandas DataFrames as images in pdf and markdown files when converting from Jupyter Notebooks

Project description

dataframe_image

A package to embed pandas DataFrames as images when convert Jupyter Notebooks to pdf or markdown documents.

Motivation

When converting Jupyter Notebooks to pdf using nbconvert, pandas DataFrames appear as either raw text or as a simple latex table. Below, we have a pdf showing both the plain text and latex DataFrame representation.

png

This package was created to embed DataFrames into pdf and markdown documents as images so that they appear exactly as they do in a Jupyter Notebook. Here, the same DataFrame as above is shown in a pdf converted using dataframe_image.

png

Installation

pip install dataframe_image

Usage

In a separate Python script, import the dataframe_image package and pass the file name of your notebook to the convert function.

>>> import dataframe_image as dfi
>>> dfi.convert('path/to/your_notebook.ipynb',
                to='pdf',
                max_rows=30,
                max_cols=10,
                ss_width=1000,
                ss_height=900,
                resize=1,
                chrome_path=None,
                limit=None
                )

The new file(s) will be saved in the same directory where the notebook resides. dataframe_image will automatically find the location of chrome on Windows, macOS, and Linux. Set the to parameter to 'md' to convert to markdown.

Dependencies

You must have the following python libraries installed

You must also have Google Chrome installed.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dataframe_image-0.0.4.tar.gz (7.0 kB view hashes)

Uploaded Source

Built Distribution

dataframe_image-0.0.4-py3-none-any.whl (14.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page