When do we use ColumnDataSource?

Is there any particular reason why we should use ColumnDataSource? Why not passing pandas dataframe columns directly?
Any advantages of ColumnDataSource we need to be aware about?

It seems one would use ColumnDataSource when wanting to link multiple plots to the same source.

I am trying to understand this same concept.

Using Pandas Dataframe, I can query for the data I want presented on a plot and plot the filtered list. I could not figure out how to specify which rows to filter for and plot only those specific rows in a ColumnDataSource.

I wanted to link the same ColumnDataSource across multiple plots for linked brushing and lasso point selection. But I do not understand how to specify a subset of rows to plot on a specific plot.

I provided an example dataset to show the faceted grid (of scatter plots) I wanted to achieve. If you are leery of other people’s excel files, the same thing is provided in jpg format.

I found some examples of hoops people jumped through to accomplish this, but seems it should be built naturally into the library.

Manual Faceted Line Plot: http://nbviewer.jupyter.org/gist/liova99/277ff4c49bf0db46502424bf9dc0e4c4

BokehUtils Library for Faceted Grids: http://bokehutils.readthedocs.io/en/latest/docs/about.html#easy-faceting

BokehExampleDataset.xlsx (15.4 KB)

···

On Thursday, July 28, 2016 at 1:34:27 AM UTC-7, Adi wrote:

Is there any particular reason why we should use ColumnDataSource? Why not passing pandas dataframe columns directly?
Any advantages of ColumnDataSource we need to be aware about?

Some clarification is probably in order. Internally, Bokeh always uses a ColumnDataSource to store data for glyphs. If you pass list or array literals directly to .circle, etc. Bokeh just creates one for you, under the covers. The CDS is the basic, fundamental data structure for serializing "table like" data to BokehJS, always.

You would use CDS "directly" if you wanted to:

* share data between plots (for linked brushing, etc)
* make the data available to a CustomJS or Bokeh server callback to update interactively

It's easy to adapt DataFrames to CDS. We didn't use Pandas DataFrames directly, because:

* We wanted to not have pandas as required dependency
* Would have to subclass DataFrame to work with our property validation/serialization system, and not even sure that would work

Thanks,

Bryan

···

On Aug 2, 2016, at 10:55 AM, [email protected] wrote:

It seems one would use ColumnDataSource when wanting to link multiple plots to the same source.

I am trying to understand this same concept.

Using Pandas Dataframe, I can query for the data I want presented on a plot and plot the filtered list. I could not figure out how to specify which rows to filter for and plot only those specific rows in a ColumnDataSource.

I wanted to link the same ColumnDataSource across multiple plots for linked brushing and lasso point selection. But I do not understand how to specify a subset of rows to plot on a specific plot.

I provided an example dataset to show the faceted grid (of scatter plots) I wanted to achieve. If you are leery of other people's excel files, the same thing is provided in jpg format.

I found some examples of hoops people jumped through to accomplish this, but seems it should be built naturally into the library.
Manual Faceted Line Plot: http://nbviewer.jupyter.org/gist/liova99/277ff4c49bf0db46502424bf9dc0e4c4
BokehUtils Library for Faceted Grids: http://bokehutils.readthedocs.io/en/latest/docs/about.html#easy-faceting

On Thursday, July 28, 2016 at 1:34:27 AM UTC-7, Adi wrote:
Is there any particular reason why we should use ColumnDataSource? Why not passing pandas dataframe columns directly?
Any advantages of ColumnDataSource we need to be aware about?

--
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/9030a11c-2ad5-4b13-87be-82b4b3b136e5%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.
<BokehExampleDataset.xlsx><ExampleDataSet.jpg>

If all you need is to convert a DataFrame once and have a plot, you will be pleased to know that as of this commit, bokeh function will try to convert DataFrame’s and dicts to a ColumnDataSource, thus reducing the need to type “magic” lines

···

On Thursday, July 28, 2016 at 11:34:27 AM UTC+3, Adi wrote:

Is there any particular reason why we should use ColumnDataSource? Why not passing pandas dataframe columns directly?
Any advantages of ColumnDataSource we need to be aware about?