如何在I
Python笔记本中的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有关详细信息,请参阅
here.有关使用IPython Notebook显示html,svg,image等的精彩示例,请参阅
here
在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