我从“ Bokeh”官方网站复制了一段代码:
import numpy as np
from bokeh.io import output_file, show
from bokeh.plotting import figure
from bokeh.transform import linear_cmap
from bokeh.util.hex import hexbin
n = 50000
x = np.random.standard_normal(n)
y = np.random.standard_normal(n)
bins = hexbin(x, y, 0.1)
p = figure(tools="wheel_zoom,reset", match_aspect=True, background_fill_color='#440154')
p.grid.visible = False
p.hex_tile(q="q", r="r", size=0.1, line_color=None, source=bins,
fill_color=linear_cmap('counts', 'Viridis256', 0, max(bins.counts)))
output_file("hex_tile.html")
show(p)
当我运行该程序时,出现以下错误消息: enter image description here
> Traceback (most recent call last):
> File "d:\vscode-text-files\hex_tile.py", line 12, in 'module'
> bins = hexbin(x, y, 0.1)
> File "D:\Program Files\Python37\lib\site-packages\bokeh\util\hex.py",
> line 198, in hexbin
> df = pd.DataFrame(dict(r=r, q=q))
> AttributeError: 'NoneType' object has no attribute 'DataFrame'
我该如何解决这个问题?