streamlit 显示时间太长

问题描述 投票:0回答:1

基于以下链接:Streamlit displot

我已经在回归数据集上尝试了自己的示例:

import streamlit as st
import pandas as pd
import plotly.figure_factory as ff
data =pd.read_csv("https://raw.githubusercontent.com/krishnaik06/Multiple-Linear-Regression/master/50_Startups.csv")
print(data.head())
print(data.shape)
hist_data =[data['R&D Spend'].values,data['Administration'].values,data['Marketing Spend'].values,data['Profit'].values]
groups =["R&D spend","Administration","Marketing Spend","Profit"]
fig =ff.create_distplot(hist_data=hist_data,group_labels=groups,bin_size=[0.1,0.25,0.5,0.75])
st.plotly_chart(fig,use_container_width=True)

shape 返回 (50,5),所以它是非常小的数据集,但是当我运行代码时,它需要太长时间并返回以下错误:

enter image description here

你能告诉我如何修复它吗?

python pandas streamlit
1个回答
1
投票
  1. 根据 Plotly 的

    create_distplot
    文档

    此函数已弃用,请改用plotly.express 函数,[...]

  2. 使用您当前的功能,我确实仍然遇到类似的问题,导致我的浏览器告诉我“此页面正在减慢Firefox”。增大垃圾箱的尺寸可以缓解这个问题:

    fig = ff.create_distplot(hist_data=hist_data, group_labels=groups, bin_size=10000)
    

    它给出:

    enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.