【发布时间】:2020-07-18 14:39:07
【问题描述】:
使用以下代码,我可以在我的 jupyter notebook 或转换后的 HTML 代码中显示漂亮的并排集中表
import pandas as pd
import numpy as np
from IPython.display import display, HTML
display(HTML("""
<style>
.output {
display: flex;
flex-direction: row;
justify-content: center;
}
</style>
"""))
df = pd.DataFrame(10000*np.ones((2,2)), columns = ['foo','bar'])
display(df)
display(df)
不过,如果我使用jupyter nbconvert --to html --no-inp myfile.ipynb 将myfile.ipynb 转换为myfile.html 而不使用代码,则表格显示时几乎没有水平空间和长滚动条,使它们相当不可用。
我可以做些什么来保持表格在 jupyter notebook 中的显示方式?
【问题讨论】:
-
我认为您需要输入“为什么它们会像这样收缩以及如何解开它们?”在问题正文中,因为没有书面的明显问题。缩小是指放大吗?
-
我放大了,因为它们在 html 中非常小。我已经澄清了这个问题。谢谢
-
我无法在我的 Mac 上重现,当我将窗口的大小更改得足够薄时,我得到的表格在 html 和 Jupyter 中看起来都像这样,但这并不相同。请问您使用的是什么浏览器和操作系统?
-
我使用的是 ubuntu 20.04 + chrome
标签: python pandas jupyter-notebook nbconvert