【问题标题】:Integrating pandas-profiling report in dash app在 dash 应用程序中集成 pandas-profiling 报告
【发布时间】:2021-07-14 21:03:16
【问题描述】:

如何将 pandas-profiling 报告集成到 dash 应用中?

Pandas Profiling

Streamlit 允许这些集成(但我很难在其中管理缓存/会话) https://discuss.streamlit.io/t/including-pandas-profiling-report-in-streamlit/473/2

但我在 dash 上没有看到任何关于此的文档。请帮忙。

【问题讨论】:

    标签: python pandas plotly-dash streamlit pandas-profiling


    【解决方案1】:

    你有两个选择:

    生成 de html 页面并将其作为资产加载到 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
    

    获取原始文本并安装 dash-dangerously-set-inner-html 以使用原始格式:

    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)])
    

    正如库名所说,不建议使用它。

    【讨论】:

    • 试过了,后一种方法。它不能很好地工作,它显示一个“静态”配置文件报告,当您单击按钮等时没有任何反应。
    • 是的,第二种方法不允许您单击所有按钮,这是我忘记提及的问题。稍后,我将通过添加此注释来更新我的答案。使用第一种解决方案,生成报告后,您可以通过将页面重定向到资源来自动加载它
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多