Reputation: 174
I'm using
jupyter nbconvert --to pdf --TemplateExporter.exclude_input=True Scorecard.ipynb
to export my notebook to a pdf. Everything runs fine, but when looking in the pdf the dataframes are shown as
<pandas.io.formats.style.Styler at 0x1ea7d7910f0>
rather than the nicely colored dataframes in the notebook. Any ideas on how to fix?
Using nbconvert to send to html then using pdfkit to convert works (kind of) The issue with that is the header overlaps the rows if the table spans multiple pages and the rows are split in half if they're at the end of apage
Upvotes: 11
Views: 1270
Reputation: 1639
I encountered the same error when trying to hide indexes in my Pandas Dataframes with df.style.hide_index()
.
Unfortunately the Pandas Styling method seems to be based purely on HTML/CSS:
The styling is accomplished using CSS. You write “style functions” that take DataFrames ..., and return like-indexed DataFrames ... with CSS "attribute: value" pairs for the values. These functions can be incrementally passed to the Styler which collects the styles before rendering.
I have not been able to find and method for converting df.style
objects into PDF through native latex tables.
There has been some effort on a Styler.to_latex() extension, but the branch died mid-2018.
Upvotes: 8