Hi,
the following code was running under a previous version of bokeh (I think 0.11.something). With bokeh 0.12.2 it throws and error:
‘’’
Test case: An from Excel imported DataFrame throws an Error with bokeh 0.12.2.
‘’’
if name == ‘main’:
import pandas
from bokeh.io import output_server, show
from bokeh.charts import Line
import subprocess
import time
hdf_name = ‘test.xlsx’
excel_df = pandas.read_excel(io = hdf_name)
print(‘excel_df: \n{}’.format(excel_df))
args = [‘python’, ‘-m’, ‘bokeh’, ‘serve’]
p = subprocess.Popen(args)
time.sleep(1) # wait for the server to run
output_server(‘test’)
p1 = Line(excel_df, title=“DataFrame from Excel”)
show(p1)
Traceback (most recent call last):
File “C:\Users…\src\bokeh_tests\excel_io.py”, line 23, in
p1 = Line(excel_df, title=“DataFrame from Excel”)
File “C:\Python34\lib\site-packages\bokeh\charts\builders\line_builder.py”, line 88, in Line
return create_and_build(LineBuilder, data, **kws)
File “C:\Python34\lib\site-packages\bokeh\charts\builder.py”, line 68, in create_and_build
builder = builder_class(*data, **builder_kws)
File “C:\Python34\lib\site-packages\bokeh\charts\builder.py”, line 297, in init
attributes = self._setup_attrs(data, kws)
File “C:\Python34\lib\site-packages\bokeh\charts\builder.py”, line 329, in _setup_attrs
source = ColumnDataSource(data.df)
File “C:\Python34\lib\site-packages\bokeh\models\sources.py”, line 90, in init
self.add(data, name)
File “C:\Python34\lib\site-packages\bokeh\models\sources.py”, line 165, in add
self.column_names.append(name)
File “C:\Python34\lib\site-packages\bokeh\core\property_containers.py”, line 19, in wrapper
self._notify_owners(old)
File “C:\Python34\lib\site-packages\bokeh\core\property_containers.py”, line 44, in _notify_owners
prop._notify_mutated(owner, old, hint)
File “C:\Python34\lib\site-packages\bokeh\core\properties.py”, line 470, in _notify_mutated
value = self.descriptor.prepare_value(obj.class, self.name, value)
File “C:\Python34\lib\site-packages\bokeh\core\properties.py”, line 272, in prepare_value
raise e
File “C:\Python34\lib\site-packages\bokeh\core\properties.py”, line 265, in prepare_value
self.validate(value)
File “C:\Python34\lib\site-packages\bokeh\core\properties.py”, line 1062, in validate
raise ValueError(“expected an element of %s, got seq with invalid items %r” % (self, invalid))
ValueError: expected an element of List(String), got seq with invalid items [1]
2016-10-02 13:23:52,063 Starting Bokeh server version 0.12.2
2016-10-02 13:23:52,066 Starting Bokeh server on port 5006 with applications at paths [’/’]
I have a guess, that it might have something to do with the names of the columns. If I create the DataFrame manually like this:
d = {‘1’: [100,50,0],
‘2’: [0,50,100]}
df = pandas.DataFrame(data=d)
and use it to create the plot, the code is working.
Thanks
Daniel