绘制DataFrame以进行散射时,Bokeh崩溃

时间:2017-04-29 17:41:05

标签: python pandas bokeh

更新3:让它在python 2上工作,见答案

更新2:它在Python 3.5.2上运行得非常好,与python 3的bokeh版本相同。我想这会使它成为python 2特定的bug,我会报告它。

更新:我正在使用bokeh的上游版本,0.12.5和python 2.7.12 当我尝试用看似有效的熊猫数据帧制作散点图时,Bokeh崩溃了。

我找不到数据框Here it is in json format有什么问题,所以你可以反序列化并自己查看。

这是追溯

File ".../plotting.py", line 13, in scatter
    p=Scatter(df, plot_width=1000, plot_height=500, sizing_mode='stretch_both')
  File "/home/shep/.local/lib/python2.7/site-packages/bokeh/charts/builders/scatter_builder.py", line 65, in Scatter
    return create_and_build(ScatterBuilder, data, **kws)
  File "/home/shep/.local/lib/python2.7/site-packages/bokeh/charts/builder.py", line 56, in create_and_build
    chart.add_builder(builder)
  File "/home/shep/.local/lib/python2.7/site-packages/bokeh/charts/chart.py", line 153, in add_builder
    builder.create(self)
  File "/home/shep/.local/lib/python2.7/site-packages/bokeh/charts/builder.py", line 512, in create
    chart.add_renderers(self, renderers)
  File "/home/shep/.local/lib/python2.7/site-packages/bokeh/charts/chart.py", line 148, in add_renderers
    self.renderers += renderers
  File "/home/shep/.local/lib/python2.7/site-packages/bokeh/core/property/containers.py", line 76, in wrapper
    result = func(self, *args, **kwargs)
  File "/home/shep/.local/lib/python2.7/site-packages/bokeh/core/property/containers.py", line 172, in __iadd__
    return super(PropertyValueList, self).__iadd__(y)
  File "/home/shep/.local/lib/python2.7/site-packages/bokeh/charts/builders/scatter_builder.py", line 95, in yield_renderers
    marker=group['marker'])
  File "/home/shep/.local/lib/python2.7/site-packages/bokeh/charts/glyphs.py", line 130, in __init__
    super(PointGlyph, self).__init__(**kwargs)
  File "/home/shep/.local/lib/python2.7/site-packages/bokeh/charts/models.py", line 84, in __init__
    self.setup()
  File "/home/shep/.local/lib/python2.7/site-packages/bokeh/charts/models.py", line 90, in setup
    self.refresh()
  File "/home/shep/.local/lib/python2.7/site-packages/bokeh/charts/models.py", line 99, in refresh
    data = self.build_source()
  File "/home/shep/.local/lib/python2.7/site-packages/bokeh/charts/glyphs.py", line 57, in build_source
    str_labels = [str(label) for label in labels]
TypeError: 'NoneType' object is not iterable

我很想知道我的数据框架有什么问题,我怎样才能让它工作。

1 个答案:

答案 0 :(得分:0)

I opened an issue on the Bokeh github显然您需要指定X轴和Y轴才能正常工作:

p=Scatter(df,
    x="Fraction of deaths caused by G20: Parkinson disease",
    y="Fraction of deaths caused by I64: Stroke")