python - Bokeh histogram will not plot, is there a solution to this old issue -




my issue seems post (albeit column types may different):

cannot plot histogram on ubuntu 14.04

the code straight out of docs http://bokeh.pydata.org/en/0.10.0/docs/user_guide/charts.html#histograms

i couldn't comment on post needed ask again if solution found...

my system suse. trying plot simple histogram of datetimes pandas df series.

>>>df            acq_date 0       2017-01-28 1       2017-01-28 ...            ... 456365  2017-07-25 456366  2017-07-25  >>>hist = histogram(df['acq_date'], title="fire frequency")  2017-08-22 11:56:15,240 error running application handler <bokeh.application.handlers.script.scripthandler object @ 0x2b6cc2c8f358>:     expected element of either column(float) or column(string), got array(['2017-    01-28t00:00:00.000000000', '2017-01-28t00:00:00.000000000',    '2017-01-28t00:00:00.000000000', ...,    '2017-07-25t00:00:00.000000000', '2017-07-25t00:00:00.000000000',    '2017-07-25t00:00:00.000000000'], dtype='datetime64[ns]') file "properties.py", line 676, in validate: raise valueerror("expected element of either %s, got %r" % (nice_join    (self.type_params), value)) traceback (most recent call last):   file "/home/byed/venv36/lib/python3.6/site-    packages/bokeh/application/handlers/code_runner.py", line 81, in run exec(self._code, module.__dict__)   file "/home/byed/job/fire/report_fire_points.py", line 118, in <module>     hist = histogram(df['acq_date'], title="fire frequency")  #,     tools='pan,wheel_zoom,box_select,reset')   file "/home/byed/venv36/lib/python3.6/site-    packages/bkcharts/builders/histogram_builder.py", line 107, in histogram     return create_and_build(histogrambuilder, data, **kw)   file "/home/byed/venv36/lib/python3.6/site-packages/bkcharts/builder.py", line 56, in create_and_build     chart.add_builder(builder)   file "/home/byed/venv36/lib/python3.6/site-packages/bkcharts/chart.py", line 155, in add_builder     builder.create(self)   file "/home/byed/venv36/lib/python3.6/site-packages/bkcharts/builder.py", line 512, in create     chart.add_renderers(self, renderers)   file "/home/byed/venv36/lib/python3.6/site-packages/bkcharts/chart.py", line 150, in add_renderers     self.renderers += renderers   file "/home/byed/venv36/lib/python3.6/site-packages/bokeh/core/property/containers.py", line 76, in wrapper     result = func(self, *args, **kwargs)   file "/home/byed/venv36/lib/python3.6/site-    packages/bokeh/core/property/containers.py", line 172, in __iadd__     return super(propertyvaluelist, self).__iadd__(y)   file "/home/byed/venv36/lib/python3.6/site-   packages/bkcharts/builders/bar_builder.py", line 221, in yield_renderers     **group_kwargs)   file "/home/byed/venv36/lib/python3.6/site-packages/bkcharts/glyphs.py", line 950, in __init__     super(histogramglyph, self).__init__(**kwargs)   file "/home/byed/venv36/lib/python3.6/site-packages/bkcharts/glyphs.py", line 490, in __init__     super(aggregateglyph, self).__init__(**kwargs)   file "/home/byed/venv36/lib/python3.6/site-packages/bkcharts/models.py", line 83, in __init__     super(compositeglyph, self).__init__(**properties)   file "/home/byed/venv36/lib/python3.6/site-packages/bokeh/core/has_props.py", line 246, in __init__     setattr(self, name, value)   file "/home/byed/venv36/lib/python3.6/site- packages/bokeh/core/has_props.py", line 274, in __setattr__     super(hasprops, self).__setattr__(name, value)   file "/home/byed/venv36/lib/python3.6/site-   packages/bokeh/core/property/descriptors.py", line 495, in __set__     self._internal_set(obj, value, setter)   file "/home/byed/venv36/lib/python3.6/site-packages/bokeh/core/property/descriptors.py", line 713, in _internal_set     value = self.property.prepare_value(obj, self.name, value)   file "/home/byed/venv36/lib/python3.6/site-packages/bokeh/core/property/bases.py", line 290, in prepare_value     raise e   file "/home/byed/venv36/lib/python3.6/site-packages/bokeh/core/property/bases.py", line 283, in prepare_value self.validate(value)   file "/home/byed/venv36/lib/python3.6/site-packages/bokeh/core/properties.py", line 676, in validate     raise valueerror("expected element of either %s, got %r" % (nice_join   (self.type_params), value))     valueerror: expected element of either column(float) or column(string),   got array(['2017-01-28t00:00:00.000000000', '2017-01-28t00:00:00.000000000',    '2017-01-28t00:00:00.000000000', ...,    '2017-07-25t00:00:00.000000000', '2017-07-25t00:00:00.000000000',    '2017-07-25t00:00:00.000000000'], dtype='datetime64[ns]') 

any appreciated.

cheers n thanks

don't use bokeh.charts (now separate bkcharts project), including histogram. bkcharts project abandoned unmaintained. however, it's pretty trivial create histograms using bokeh.plotting stable , well-supported core api of bokeh:

import numpy np bokeh.io import show, output_file bokeh.plotting import figure  data = np.random.normal(0, 0.5, 1000) hist, edges = np.histogram(data, density=true, bins=50)  x = np.linspace(-2, 2, 1000)  p = figure() p.quad(top=hist, bottom=0, left=edges[:-1], right=edges[1:], line_color="white")  output_file("hist.html") show(p) 

enter image description here

alternatively, if want very-high level statistical charting api on top of bokeh, check out holoviews:

http://holoviews.org/

holoviews better bokeh.charts in every way, , more importantly maintained active team. officially endorsed core bokeh dev team best , supported very-high-level api on top of bokeh going forward.





wiki

Comments

Popular posts from this blog

python - Read npy file directly from S3 StreamingBody -

python - Minimize function with Scipy minimize -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -