☰Read-only archive⌕
Looking for help with Bokeh?

This is a read-only archive. Ask questions and join the conversation on GitHub.

Visit Community Support on GitHub →
Archived discussions · Captured October 28, 2026

Multiple boolean filters to same view

Community Support
Dave_King
Dave_King

I could use direction on how to apply multiple filters to a view in cdsview

The following functions as a single source data point, however I’m looking to apply a second filter and second source data point.

    booleans = [True if y_val > float(LowerFilter.value) and y_val < float(UpperFilter.value) else False for y_val in source.data[FilterSelect.value]]
    view = CDSView(source=source, filters=[BooleanFilter(booleans)])

The second filter would look like this in single filter application

    booleans = [True if y_val > float(LowerFilter2.value) and y_val < float(UpperFilter2.value) else False for y_val in source.data[FilterSelect2.value]]
    view = CDSView(source=source, filters=[BooleanFilter(booleans)])

How do I combine them into a single view?

⌁   Link to post
Bryan
Bryan

Bokeh 3.0 changed to only allow configuration of a single filter at a time, rather than a list of filters. Supporting list of filters was just too fragile and difficult to maintain. Per the docs:

https://docs.bokeh.org/en/latest/docs/reference/models/sources.html#bokeh.models.CDSView

filters can be combined with standard Python boolean operators. So, presumably something like:

cds_view.filter = BooleanFilter(booleans)

# later
cds_view.filter &= BooleanFilter(more_booleans)

I say “presumably” because, without a complete Minimal Reproducible Example to actually try out and run, the best I can do for you is point at relevant documentation and speculate.

For Bokeh 2.4.3 you should just be able to append the new filter to the existing list of filters. Or you can logical-and the lists of bool values together manually, and then set the booleans property of the existing filter to this new and’ed list.

Edit: note also for version 3.0, views no longer have a source property.

⌁   Link to post

End of archived discussion · Replies are disabled