cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
cancel
Showing results for 
Search instead for 
Did you mean: 

Displaying HTML Output

DavidWrench
New Contributor II

I am trying to display the html output or read in an html file to display in databricks notebook from pandas-profiling.

import pandas as pd import pandas_profiling

df = pd.read_csv("/dbfs/FileStore/tables/my_data.csv", header='infer', parse_dates=True, encoding='UTF-8')

profile = pandas_profiling.ProfileReport(df) Out[13]: <pandas_profiling.ProfileReport at 0x7f30e0b55780>

profile.to_html() Out[19]: '<!doctype html>\n\n<html lang="en">\n<head>\n <meta charset="utf-8">\n\n <title>Profile report</title>... WARNING: skipped 429584 bytes of output

Error on dislpayHtml()

displayHTML(profile)Py4JException: An exception was raised by the Python Proxy. Return Message: x

I could also output to html file:

profile.to_file(outputfile="/tmp/my_profiling.html")

but how would I read that in? is there a %html command?

4 REPLIES 4

DavidWrench
New Contributor II

I am sorry it is a mess, the code formatting on here does not escape the code I tried to embed.

anandkn1884
New Contributor II

Hi,

Took me a while to find a simple solution. Found two ways. Hope they work.

1.

- Read the html file content

html_file_content = open("output.html", 'r').read()

- Use displayHTML on the html_file_content

displayHTML(html_file_content)

2. Note: df is the dataframe

profile = pp.ProfileReport(df)

p = profile.to_html()

displayHTML(p)

christopher_bro
New Contributor II

Have you tried using

displayHTML(profile.to_html())

It worked for me, but I didn't have the warning or Exception, you had, when I used

displayHTML(profile)

Bendu_Preez
New Contributor II

What eventually worked for me was displayHTML(profile.to_html()) for the pandas_profiling and displayHTML(profile.html) for the spark_profiling.

Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.