CDS can automatically initialize from a Pandas GroupBy, but there's not a *public* API for updating. You should be able to do this, for now:
source.data = source._data_from_groupy(group)
However, PLEASE NOTE: Code that uses this now WILL have to change in the near future. As we approach 1.0 the entire API surface is being re-visited, and appropriately decorated to maintain rigorously under test. This method, being useful for people to use, will have to become "internal" or "public" instead of pure private (i.e. it will have to lose the underscore, at minimum).
Thanks,
Bryan
···
On Sep 29, 2017, at 13:43, Jonathan Bennett <[email protected]> wrote:
When you set a groupby as a ColumnDataSource, how do you update the ColumnDataSource.data?
A Pandas DataFrame object
source = ColumnDataSource(data=df)
to update:
source.data = dict(df)
A Pandas GroupBy object
group = df.groupby(('colA', 'ColB'))
source = ColumnDataSource(data=group)
to update:
???
When I try
source.data = dict(group)
I get: "error handling message Message 'PATCH-DOC' (revision 1): TypeError("attribute of type 'list' is not callable",)"
Do I need to manipulate the group object when I pass the updated version back to the ColumnDataSource?