【问题标题】:Nbconvert doesn't display styler dataframe from jupyter notebookNbconvert 不显示来自 jupyter notebook 的样式器数据框
【发布时间】:2019-12-22 04:53:13
【问题描述】:

我正在使用

jupyter nbconvert --to pdf --TemplateExporter.exclude_input=True Scorecard.ipynb

将我的笔记本导出为 pdf。一切运行良好,但在查看 pdf 时,数据框显示为

 <pandas.io.formats.style.Styler at 0x1ea7d7910f0>

而不是笔记本中颜色漂亮的数据框。关于如何解决的任何想法?

使用 nbconvert 发送到 html,然后使用 pdfkit 转换作品(有点)如果表格跨越多个页面,标题会与行重叠,如果行在末尾,则行被分成两半页面

【问题讨论】:

    标签: python pdf nbconvert


    【解决方案1】:

    我在尝试使用 df.style.hide_index() 隐藏我的 Pandas 数据帧中的索引时遇到了同样的错误。

    不幸的是,Pandas Styling 方法似乎完全基于 HTML/CSS:

    样式是使用 CSS 完成的。您编写“样式函数”,采用 DataFrames ...,并返回类似索引的 DataFrames ... 并使用 CSS “attribute: value” 对作为值。这些函数可以增量传递给在渲染之前收集样式的 Styler。

    我一直无法找到将df.style 对象通过本机 Latex 表转换为 PDF 的方法。

    Styler.to_latex() 扩展上已经做了一些努力,但该分支在 2018 年年中死亡。

    【讨论】:

      猜你喜欢
      • 2020-05-21
      • 2017-06-29
      • 2018-02-02
      • 2019-08-27
      • 2020-11-09
      • 2018-04-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多