On Mar 6, 2018, at 01:45, Joris Nettelstroth <[email protected]> wrote:
Hi there,
I had the exact same question in December and ended up with the same solution :
source.data = current.to_dict('list')
Redirecting to Google Groups
How would one proceed to use a "real NumPy array" instead of the list? The following fail for me:
source.data = current.values
source.data = current.to_records()
Regards
Am Mittwoch, 28. Februar 2018 17:54:42 UTC+1 schrieb Bryan Van de ven:
Hi,
This is a known bug, it specifically affects the combination of data tables and the fast binary array protocol:
DeserializationError when editing Data Table · Issue #7417 · bokeh/bokeh · GitHub
Regarding things being Pythonic, first it must be remembered that the large majority of Bokeh is actually not Python. In order to make all the work for automatic serialization, synchronization, communication etc. with a remote JavaScript runtime "just happen" transparently, there are definitely a handful of tradeoffs. That said, I don't personally consider the way it is done in the example to be non-pythonic. A bokeh CDS is not a DataFame, and spelling out dicts seems very common usage in all kinds of situations.
Specifically regarding using
source.data = current.to_dict('list')
Yes that will work, but using a list instead of a real NumPy array means that Bokeh will fall back to pure JSON transport, instead of using the much more efficient binary transport available for NumPy arrays If your data sizes are small it probably does not make much difference either way, but for things like e.g. a 1000x1000 image, it means the difference between a smooth quick update, vs being too slow to be usable at all.
Thanks,
Bryan
> On Feb 28, 2018, at 07:06, Jonathan Bennett <[email protected]> wrote:
>
> The Demo code from the Bokeh Gallery produces an "error" or "warning" without any modification.
> https://demo.bokehplots.com/apps/export_csv
>
> Bokeh 0.12.13 & 0.12.14
> Python 3.5.4
>
> I used this code a few months back and didn't get the error, so it might be related to a recent upgrade?
>
> Error:
> 2018-02-28 08:48:20,582 error handling message Message 'PATCH-DOC' (revision 1): DeserializationError("Seq(Any) expected a list or None, got {'0': 13567.314696399999}",)
>
> Code causing problem?
>
> source.data = {
> 'name' : current.name,
> 'salary' : current.salary,
> 'years_experience' : current.years_experience,
> }
>
>
> More generically, is there a better way to update the ".data" of the ColumnDataSource?
>
> Listing all columns of a dataframe doesn't seem to be pythonic.
>
> Is this the recommended method?
> source.data = current.to_dict('list')
>
> I tried it and it seemed to work, without the DeserializationError listed above. But I want to make sure I'm not breaking any design assumptions about the properties of ColumnDataSource.
>
> Thanks.
> Jonathan
>
>
>
> --
> 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 bokeh+un...@continuum.io.
> To post to this group, send email to bo...@continuum.io.
> To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/5a04265b-d198-4e20-87fe-facf06844ea7%40continuum.io\.
> For more options, visit https://groups.google.com/a/continuum.io/d/optout\.
--
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/1060b951-e219-43a8-b8ee-0ea388f4333f%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.