How do I extract data from a Bokeh ColumnDatasource
If the source input is a Pandas DataFrame, you can use the Standard method:
source = ColumnDataSource(
data= pd.DataFrame( dict(
x=[1, 2, 3, 4, 5],
y=[2, 5, 8, 2, 7],
desc=['A', 'b', 'C', 'd', 'E'],
))
)
print( source.data['x'].max() )
A ColumnDataSource object has an attribute data
which will return the python dictionary used to create the object in the first place.
from bokeh.plotting import ColumnDataSource
# define ColumnDataSource
source = ColumnDataSource(
data=dict(
x=[1, 2, 3, 4, 5],
y=[2, 5, 8, 2, 7],
desc=['A', 'b', 'C', 'd', 'E'],
)
)
# find max for variable 'x' from 'source'
print( max( source.data['x'] ))