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
You can visualize a pandas dataframe in Jupyter notebooks by using the display(<dataframe-name>) function. The display() function is supported only on PySpark kernels. The Qviz framework supports 1000 rows and 100 columns.
The nbconvert tool, jupyter nbconvert , converts notebooks to various other formats via Jinja templates. The nbconvert tool allows you to convert an . ipynb notebook file into various static formats including: HTML. LaTeX.
The Jupyter Notebook has an option to export the notebook to many formats. It can be accessed by clicking File -> Download as -> PDF via LaTeX (or PDF via HTML - not visible in the screenshot).
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With