我最近开始编码,现在正在对开源 Corona 数据进行数据分析。我在 Jupyter Notebook 中使用 Python3 构建了一个交互式图表。唯一的问题是,我构建了一个交互,但它仅在笔记本内部显示,而不是在导出为 html 时显示。有人可以告诉我这是为什么吗?提前谢谢了。
代码:
# Import the necessary packages
import pandas as pd
import numpy as np
import requests
import io
from bokeh.io import push_notebook,output_file
from bokeh.io import show, curdoc
from bokeh.plotting import figure, output_notebook
from bokeh.models import HoverTool, ColumnDataSource, Select
from bokeh.layouts import row
from bokeh.models.tickers import FixedTicker
from bokeh.models.callbacks import CustomJS
from ipywidgets import interact
output_notebook()
#---------------------------------------------------------------------------------------------------
# Import the data
#---------------------------------------------------------------------------------------------------
url = 'https://data.humdata.org/hxlproxy/api/data-preview.csv?url=https%3A%2F%2Fraw.githubusercontent.com%2FCSSEGISandData%2FCOVID-19%2Fmaster%2Fcsse_covid_19_data%2Fcsse_covid_19_time_series%2Ftime_series_covid19_confirmed_global.csv&filename=time_series_covid19_confirmed_global.csv'
s=requests.get(url).content
url2 = 'https://data.humdata.org/hxlproxy/api/data-preview.csv?url=https%3A%2F%2Fraw.githubusercontent.com%2FCSSEGISandData%2FCOVID-19%2Fmaster%2Fcsse_covid_19_data%2Fcsse_covid_19_time_series%2Ftime_series_covid19_deaths_global.csv&filename=time_series_covid19_deaths_global.csv'
s2 =requests.get(url2).content
df = pd.read_csv(io.StringIO(s.decode('utf-8')))
df = df.fillna("")
df2 = pd.read_csv(io.StringIO(s2.decode('utf-8')))
df2 = df2.fillna("")
#---------------------------------------------------------------------------------------------------
# Number of reported Corona cases
#---------------------------------------------------------------------------------------------------
慕标琳琳
相关分类