Cannot recreate example HeatMap

Hello experts,
I copy pasted the example code for the creation of a HeatMap found here in the Docs, but I get the following errors when I run python heatmap.py (which is a file where I copy-pasted the code).

By the way, I need to plot a heatmap of a nxn matrix with positive real values between 0 and 1, is HeatMap the correct way to do that in Bokeh?

Many thanks,
Enrico Guiraud

Traceback (most recent call last):
File “heatmap.py”, line 8, in
hm = HeatMap(data, x=‘fruit’, y=‘sample’, values=‘fruit_count’, title=‘Fruits’, stat=None)
File “/users/ml/ruft7045/.conda/envs/local/lib/python2.7/site-packages/bokeh/charts/builders/heatmap_builder.py”, line 92, in HeatMap
chart = create_and_build(HeatMapBuilder, data, xgrid=xgrid, ygrid=ygrid, **kw)
File “/users/ml/ruft7045/.conda/envs/local/lib/python2.7/site-packages/bokeh/charts/builder.py”, line 67, in create_and_build
chart.add_builder(builder)
File “/users/ml/ruft7045/.conda/envs/local/lib/python2.7/site-packages/bokeh/charts/chart.py”, line 149, in add_builder
builder.create(self)
File “/users/ml/ruft7045/.conda/envs/local/lib/python2.7/site-packages/bokeh/charts/builder.py”, line 512, in create
self.process_data()
File “/users/ml/ruft7045/.conda/envs/local/lib/python2.7/site-packages/bokeh/charts/builders/heatmap_builder.py”, line 171, in process_data
columns=self.values.selection)
File “/users/ml/ruft7045/.conda/envs/local/lib/python2.7/site-packages/bokeh/charts/attributes.py”, line 198, in setup
self.attr_map = self._create_attr_map(self.data.to_df(), self.columns)
File “/users/ml/ruft7045/.conda/envs/local/lib/python2.7/site-packages/bokeh/charts/attributes.py”, line 168, in _create_attr_map
self._generate_items(df, columns)
File “/users/ml/ruft7045/.conda/envs/local/lib/python2.7/site-packages/bokeh/charts/attributes.py”, line 249, in _generate_items
bin_count=len(self.iterable), aggregate=False)
File “/users/ml/ruft7045/.conda/envs/local/lib/python2.7/site-packages/bokeh/charts/stats.py”, line 311, in init
super(Bins, self).init(**properties)
File “/users/ml/ruft7045/.conda/envs/local/lib/python2.7/site-packages/bokeh/charts/stats.py”, line 56, in init
self._refresh()
File “/users/ml/ruft7045/.conda/envs/local/lib/python2.7/site-packages/bokeh/charts/stats.py”, line 62, in _refresh
self.calculate()
File “/users/ml/ruft7045/.conda/envs/local/lib/python2.7/site-packages/bokeh/charts/stats.py”, line 344, in calculate
self.source.add(binned.tolist(), name=self.bin_column)
AttributeError: ‘Categorical’ object has no attribute ‘tolist’

HeatMap is one way to do that, you could also use the slightly lower level bokeh.plotting interface, an example is here:

  http://bokeh.pydata.org/en/latest/docs/gallery/unemployment.html

Can you confirm what version of Bokeh you are running? It is always important to report versions when asking for help or reporting an issue.

Thanks,

Bryan

···

On Mar 16, 2016, at 9:27 AM, [email protected] wrote:

Hello experts,
I copy pasted the example code for the creation of a HeatMap found here in the Docs, but I get the following errors when I run `python heatmap.py` (which is a file where I copy-pasted the code).

By the way, I need to plot a heatmap of a nxn matrix with positive real values between 0 and 1, is HeatMap the correct way to do that in Bokeh?

Many thanks,
Enrico Guiraud

Traceback (most recent call last):
  File "heatmap.py", line 8, in <module>
    hm = HeatMap(data, x='fruit', y='sample', values='fruit_count', title='Fruits', stat=None)
  File "/users/ml/ruft7045/.conda/envs/local/lib/python2.7/site-packages/bokeh/charts/builders/heatmap_builder.py", line 92, in HeatMap
    chart = create_and_build(HeatMapBuilder, data, xgrid=xgrid, ygrid=ygrid, **kw)
  File "/users/ml/ruft7045/.conda/envs/local/lib/python2.7/site-packages/bokeh/charts/builder.py", line 67, in create_and_build
    chart.add_builder(builder)
  File "/users/ml/ruft7045/.conda/envs/local/lib/python2.7/site-packages/bokeh/charts/chart.py", line 149, in add_builder
    builder.create(self)
  File "/users/ml/ruft7045/.conda/envs/local/lib/python2.7/site-packages/bokeh/charts/builder.py", line 512, in create
    self.process_data()
  File "/users/ml/ruft7045/.conda/envs/local/lib/python2.7/site-packages/bokeh/charts/builders/heatmap_builder.py", line 171, in process_data
    columns=self.values.selection)
  File "/users/ml/ruft7045/.conda/envs/local/lib/python2.7/site-packages/bokeh/charts/attributes.py", line 198, in setup
    self.attr_map = self._create_attr_map(self.data.to_df(), self.columns)
  File "/users/ml/ruft7045/.conda/envs/local/lib/python2.7/site-packages/bokeh/charts/attributes.py", line 168, in _create_attr_map
    self._generate_items(df, columns)
  File "/users/ml/ruft7045/.conda/envs/local/lib/python2.7/site-packages/bokeh/charts/attributes.py", line 249, in _generate_items
    bin_count=len(self.iterable), aggregate=False)
  File "/users/ml/ruft7045/.conda/envs/local/lib/python2.7/site-packages/bokeh/charts/stats.py", line 311, in __init__
    super(Bins, self).__init__(**properties)
  File "/users/ml/ruft7045/.conda/envs/local/lib/python2.7/site-packages/bokeh/charts/stats.py", line 56, in __init__
    self._refresh()
  File "/users/ml/ruft7045/.conda/envs/local/lib/python2.7/site-packages/bokeh/charts/stats.py", line 62, in _refresh
    self.calculate()
  File "/users/ml/ruft7045/.conda/envs/local/lib/python2.7/site-packages/bokeh/charts/stats.py", line 344, in calculate
    self.source.add(binned.tolist(), name=self.bin_column)
AttributeError: 'Categorical' object has no attribute 'tolist'

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/2ba6502c-f12e-47a1-8113-17a42d55957e%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.