dataframe-image is a Python library that enables embedding pandas DataFrames as images in PDF and Markdown files when converting from Jupyter Notebooks. It ensures DataFrames, including any applied styling, appear exactly as they do in a Jupyter Notebook, rather than as raw text or simple LaTeX tables. The library also provides functionality to export individual DataFrames as image files from Python scripts. It is actively maintained, with version 0.2.7 being the current release.
pip install dataframe-imageVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to create a styled pandas DataFrame and export it as a PNG image using `dataframe_image.export`. The `dfi.export` function captures the DataFrame's appearance, including styling, and saves it to the specified file.
Explicitly install 'pip install "dataframe_image[playwright]"' or configure `table_conversion='chrome'` or `table_conversion='selenium'` in your export/convert calls. Ensure the necessary browser (Chromium/Firefox) is installed if using browser-based conversion.
Review the official documentation for updated Jupyter notebook integration methods if you rely on direct file insertions. For most users using the 'Download as' menu option, this change should be handled by the Jupyter frontend automatically.
Ensure Google Chrome/Chromium or Firefox (for Selenium) is installed. If issues arise, try updating your browser, updating `dataframe-image`, or switching to an alternative backend like `playwright` or `matplotlib` using the `table_conversion` parameter. For Playwright, run `playwright install` after `pip install "dataframe_image[playwright]"`.
For full styling fidelity, use a browser-based backend (Playwright, Chrome, Selenium). If `matplotlib` is necessary, be aware of its styling limitations and adjust your DataFrame's presentation accordingly.
Prepend `await` to your `export` or `convert` calls and ensure the function is defined as `async` if it's not at the top level of a script.
Try setting `table_conversion='matplotlib'` or `table_conversion='playwright'` to see if a different backend resolves the temporary file issue. Ensure your user has write permissions to the temporary directory. Restarting your environment or computer might also help clear transient issues.
Verify that your selected browser (Chrome/Chromium for 'chrome'/'html2image', Firefox for 'selenium', or Playwright's browsers) is installed and accessible. Consider upgrading or downgrading your browser or `dataframe-image` package. Switching to `table_conversion='playwright'` (with `pip install "dataframe_image[playwright]"` and `playwright install`) is often a robust solution.
Ensure Google Chrome is installed. If it is, `dataframe-image` often auto-detects it. If not, you might need to manually specify the path using the `chrome_path` parameter in `dfi.export()` or `dfi.convert()`, or install a browser using Playwright and use that backend.
Install a full LaTeX distribution (e.g., TeX Live on Linux/macOS, MiKTeX on Windows). Alternatively, use a browser-based conversion method for PDF output by setting `to='pdf'` and configuring `table_conversion` to a browser backend (e.g., `'playwright'`).