import pandas as pd
from bokeh.plotting import figure, show
from bokeh.io import output_notebook
output_notebook()
df = pd.read_csv("covid_19_india.csv")
melted_df = pd.melt(df, id_vars=['Date'], value_vars=['ConfirmedIndianNational', 'Deaths'])
melted_df.head()
p = Bar(melted_df, label="Date", values="value", group="variable", legend="top_left",ylabel='Values')
我尝试了此代码并收到错误消息NameError:名称“ Bar”未定义
如何解决此问题
您不是从库“ bokeh”中导入Bar。只需在顶部添加此行即可解决您的问题:
from bokeh.charts import Bar