
Hi all, this is a duplicate of python - Get the number of elements returned by a CDSView in Bokeh - Stack Overflow
Given the following MRE, is it possible to access or print the number of elements resulting from the application of the CDSView filter on the ColumnDataSource in Bokeh? In this simple case, I’d like to get the information that 3 rows are returned and, if possible, access the index of ColumnDataSource.data of the filtered rows.
from bokeh.models import BooleanFilter, CDSView, ColumnDataSource
from bokeh.plotting import figure, show
source = ColumnDataSource(data=dict(x=[1, 2, 3, 4, 5], y=[1, 2, 3, 4, 5]))
booleansX = [True if x_val < 5 else False for x_val in source.data['x']]
booleansY = [True if y_val > 1 else False for y_val in source.data['y']]
view = CDSView(source=source, filters=[BooleanFilter(booleansX), BooleanFilter(booleansY)])
p_filtered = figure(height=300, width=300)
p_filtered.circle(x="x", y="y", size=10, source=source, view=view)
show(p_filtered)
Note that this MRE is not the actual real data, I am just hoping to get this insight to debug a code using much larger CDS.
Thanks loads!



