2

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
  • 9,316
  • 11
  • 49
  • 70

2 Answers2

6

Use this

from IPython.display import HTML

HTML(filename="profiling/z2pDecisionTreeProfiling.html")
Ankit Kumar Rajpoot
  • 5,032
  • 1
  • 38
  • 28
5

You need to invoke IPython's HTML function:

 HTML(s.set_table_attributes("border=1").render())
eduffy
  • 37,790
  • 12
  • 92
  • 91