Integrating pandas-profiling report in dash app

1k views Asked by At

How to integrate pandas-profiling report into a dash app?

Pandas Profiling

Streamlit allows these integrations (but I'm having a hard time managing cache/sessions in it) https://discuss.streamlit.io/t/including-pandas-profiling-report-in-streamlit/473/2

But I don't see any documentation regarding this on dash. Please help.

1

There are 1 answers

2
Eduardo Fernando On

You have 2 options:

Generate de html page and loadt it as an asset in Dash:

1 - Create the Report  
profile = ProfileReport(df, title="Pandas Profiling Report")
profile.to_file("your_report.html")

2 - Load the html report
https://github.com/plotly/dash-core-components/issues/429

Get the raw text and install dash-dangerously-set-inner-html to use it in raw format:

1- Install the lib

pip install dash-dangerously-set-inner-html

2- Create the raw report

profile = ProfileReport(df, title="Pandas Profiling Report")
text_raw = profile.to_html()

3- Use it in your dash

app.layout = html.Div([
dash_dangerously_set_inner_html.DangerouslySetInnerHTML('''HTML CODE HERE''')])

app.layout = html.Div([
dash_dangerously_set_inner_html.DangerouslySetInnerHTML(text_raw)])

As the lib's name says, it's not recommended to use it.