6

I can create an html file using this code:

with open(file_loc+'file.html', 'w') as html:
    html.write(s.set_table_attributes("border=1").render())

How can I show the output in Jupyter Notebooks without creating the file?

If I simply try to render it in Jupyter (shown below) then it shows the html code instead of displaying the desired output that I would see in my browser:

from IPython.core.display import display, HTML
s.set_table_attributes("border=1").render()
sparrow
  • 10,794
  • 12
  • 54
  • 74

2 Answers2

9

Use this

from IPython.display import HTML

HTML(filename="profiling/z2pDecisionTreeProfiling.html")
Ankit Kumar Rajpoot
  • 5,188
  • 2
  • 38
  • 32
7

You need to invoke IPython's HTML function:

 HTML(s.set_table_attributes("border=1").render())
eduffy
  • 39,140
  • 13
  • 95
  • 92