cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
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.

Join Us as a Local Community Builder!

Passionate about hosting events and connecting people? Help us grow a vibrant local community—sign up today to get started!

Sign Up Now