2

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.

bitsplease
  • 31
  • 1

1 Answers1

1

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.

Eduardo Fernando
  • 619
  • 10
  • 17
  • Tried it, the latter approach. It does not work well, it displays a "static" profile report, and nothing happens when you click the buttons etc. – bitsplease Jun 17 '21 at 20:14
  • Yes, a second approach doesn't allow you to click all the buttons, that's a problem I forgot to mention. Later, I will update my answer by adding this note. Use the first solution and after the report is generated you can load it automatically by redirecting the page to the resource – Eduardo Fernando Jun 24 '21 at 17:10