下面的代码(我得到了from a different SO question)应该打印出一个带有一些彩色单元格的表。但是,它不会以彩色打印:
import pandas as pd
from IPython.core.display import HTML
from IPython.display import display
df = pd.DataFrame([[2,3,1], [3,2,2], [2,4,4]], columns=list("ABC"))
df.style.apply(lambda x: ["background: red" if v > x.iloc[0] else "" for v in x], axis = 1)
df
print(df)
display(df)
display(HTML(df.to_html()))
print('hi')
但是,根据我上面链接的the SO example,它应该是这样的:
这可能是一些有用的信息:
(stats_env) raj@r-sb2:~/repos/fix_print$ jupyter --version
jupyter core : 4.6.3
jupyter-notebook : 6.1.1
qtconsole : not installed
ipython : 7.17.0
ipykernel : 5.3.4
jupyter client : 6.1.6
jupyter lab : not installed
nbconvert : 5.6.1
ipywidgets : not installed
nbformat : 5.0.7
traitlets : 4.3.3
你又在打印df了! 评论最后一部分。它会起作用的
相关问题 更多 >
编程相关推荐