繁体   English   中英

在IPython Notebook的Pandas DataFrame单元格中包含HTML?

[英]Include HTML in a Pandas DataFrame cell in the IPython Notebook?

如何在IPython笔记本中的DataFrame生成的表中包含HTML?

例如,我希望能够做到这样的事情:

pd.DataFrame({
    "text": ["Hello <strong>world</strong>"],
})

生成一个类似于的表:

<table>
  <tr><th></th><th>text</th></tr>
  <tr><th>0</th><td>Hello <strong>world</strong></tr>
</table>

您是否尝试过pandas.DataFrame.to_html有关详细信息,请参阅此处 有关使用IPython Notebook显示html,svg,image等的精彩示例,请参阅此处

在IPython Notebook上像这样工作;

from IPython.display import HTML
data = pd.DataFrame({'A':[1,2,3,4,5],'B':[6,7,8,9,10]})
h = HTML(data.to_html());h

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM