0

我有一个Blaze数据框df,如下所示:

在此处输入图像描述

我正在尝试在散景中制作一个条形图overall,将 x 轴范围作为 x 轴范围,聚合在wordcount列上。

这是我尝试过的代码:

from bokeh.charts import Bar, show
from bokeh.io import output_notebook

p = Bar(df,"overall",values = "wordcount",title="Bar Plot")

output_notebook()

show(p)

但我收到如下错误:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-3-6670bae09dbd> in <module>()
      2 from bokeh.io import output_notebook
      3 
----> 4 p = Bar(df,"overall",values = "wordcount",title="Bar Plot")
      5 
      6 output_notebook()

/home/anaconda2/lib/python2.7/site-packages/bokeh/charts/builders/bar_builder.pyc in Bar(data, label, values, color, stack, group, agg, xscale, yscale, xgrid, ygrid, continuous_range, **kw)
    319     kw['y_range'] = y_range
    320 
--> 321     chart = create_and_build(BarBuilder, data, **kw)
    322 
    323     # hide x labels if there is a single value, implying stacking only

/home/anaconda2/lib/python2.7/site-packages/bokeh/charts/builder.pyc in create_and_build(builder_class, *data, **kws)
     66     # create the new builder
     67     builder_kws = {k: v for k, v in kws.items() if k in builder_props}
---> 68     builder = builder_class(*data, **builder_kws)
     69 
     70     # create a chart to return, since there isn't one already

/home/anaconda2/lib/python2.7/site-packages/bokeh/charts/builder.pyc in __init__(self, *args, **kws)
    292             # make sure that the builder dimensions have access to the chart data source
    293             for dim in self.dimensions:
--> 294                 getattr(getattr(self, dim), 'set_data')(data)
    295 
    296             # handle input attrs and ensure attrs have access to data

/home/anaconda2/lib/python2.7/site-packages/bokeh/charts/properties.pyc in set_data(self, data)
    170             data (`ChartDataSource`): the data source associated with the chart
    171         """
--> 172         self.selection = data[self.name]
    173         self._chart_source = data
    174         self._data = data.df

TypeError: 'NoneType' object has no attribute '__getitem__'

谁能帮我解决这个问题?

4

0 回答 0