使用Bokeh

时间:2016-08-18 13:37:03

标签: python-2.7 bokeh blaze

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

enter image description here

我正在尝试在bokeh中创建一个条形图,其中overall为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/jobsism10/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/jobsism10/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/jobsism10/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/jobsism10/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__'

任何人都可以帮我解决这个问题吗?

0 个答案:

没有答案