Export pandas Styled table to image file

As mentioned in the comments, you can use the render property to obtain an HTML of the styled table:

html = styled_table.render()

You can then use a package that converts html to an image. For example, IMGKit: Python library of HTML to IMG wrapper. Bear in mind that this solution requires the installation of wkhtmltopdf, a command line tool to render HTML into PDF and various image formats. It is all described in the IMGKit page.

Once you have that, the rest is straightforward:

import imgkit
imgkit.from_string(html, 'styled_table.png')

Leave a Comment