ContinuumIO/Bokeh — pull request #38 by stucchio (2013-04-21 22:39:40+00:00)
Title: Unable to use pandas data model (with fix)

I have the following code:

p = mpl.PlotClient('defaultuser', serverloc='http://localhost:5006', userapikey='nokey')
p.use_doc('whisper')
data_source = p.make_source(metrics)
p.plot("time", "foo.bar", data_source=data_source, is_x_date=True)

where `metrics` is a pandas `DataFrame`. One can also run `examples/pandas_example.py` with the distribution. When I run this, I get the following error:

Traceback (most recent call last):
File "lib/whisper_loader.py", line 59, in
p.plot("time", "foo.bar", data_source=data_source, is_x_date=True)
File "/home/stucchio/src/graphene/graphite_server/local/lib/python2.7/site- packages/bokeh/mpl.py", line 568, in plot
scatter=scatter
File "/home/stucchio/src/graphene/graphite_server/local/lib/python2.7/site- packages/bokeh/mpl.py", line 182, in plot
plotsource.update()
File "/home/stucchio/src/graphene/graphite_server/local/lib/python2.7/site-packages/bokeh/bbmodel.py", line 114, in update
self.client.update(self)
File "/home/stucchio/src/graphene/graphite_server/local/lib/python2.7/site- packages/bokeh/bbmodel.py", line 180, in update
model.to_json(include_hidden=True)))
File "/home/stucchio/src/graphene/graphite_server/local/lib/python2.7/site-packages/bokeh/specialmodels/pandasmodel.py", line 62, in to_json
data = make_source(index=data.index, **data)
TypeError: make_source() argument after ** must be a mapping, not DataFrame

The issue is that Bokeh is passing a dataframe into `make_source`, i.e. `make_source(**data_frame)`. Fixing that bug is pretty straightforward, albeit less than pretty - I build a dict out of the dataframe in the obvious way and passed that in.

I'm uncertain if this fully resolves the issue. At first I was seeing the following js error in the browser:

error with binder
DataRange1d {get_obj: function, resolve_ref: function, convert_to_ref: function, cid: "c-61E9A5CB935B44048D6800EBF2BDA75A", attributes: Object…}
change:data

However, after I started poking around at the coffee script (nothing more than putting in `console.log`), this error went away, and I am unable to reproduce it.