我在 Python 中使用 Plotly 在 Jupyter Notebook 中创建了一些图,不幸的是,每次我打开 Jupyter Notebook 时,我都必须重新加载数据才能在 Plotly 中看到这些图,为什么会发生这种情况,如果我能以某种方式使图每次生成我什么时候运行 Jupyter Notebook 了?请给我一些建议,这对我来说真的是个大问题。
例如像这样的代码,当我打开它时,我必须重新加载数据集才能在 Jupyter Notebook 中再次显示它:
#Size of the plot
figsize=(10,5)
#Count of values of good and bad credits in the dataset
goodCount = data[data["Risk"]== 'good']["Risk"].value_counts().values
badCount = data[data["Risk"]== 'bad']["Risk"].value_counts().values
#Bar fo good credit
trace0 = go.Bar(x = data[data["Risk"]== 'good']["Risk"].value_counts().index.values,
y = data[data["Risk"]== 'good']["Risk"].value_counts().values,
name='Good credit',
text= goodCount,
textposition="auto",
marker = dict(color = "green", line=dict(color="black", width=1),),opacity=1)
#Bar of bad credit
trace1 = go.Bar(x = data[data["Risk"]== 'bad']["Risk"].value_counts().index.values, …Run Code Online (Sandbox Code Playgroud)