Skip to content

Commit

Permalink
docs: Adapt examples for user guide
Browse files Browse the repository at this point in the history
  • Loading branch information
dangotbanned committed Nov 13, 2024
1 parent 64dc7fd commit 3efc144
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions doc/user_guide/transform/filter.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ expressions and objects:

We'll show a brief example of each of these in the following sections

.. _filter-expression:

Filter Expression
^^^^^^^^^^^^^^^^^
A filter expression uses the `Vega expression`_ language, either specified
Expand Down Expand Up @@ -189,12 +191,26 @@ Then, we can *invert* this selection using ``~``:
chart.transform_filter(~between_1950_60)

We can further refine our filter by *composing* multiple predicates together.
In this case, using ``alt.datum``:
In this case, using ``datum``:

.. altair-plot::

chart.transform_filter(~between_1950_60 & (datum.age <= 70))

When passing multiple predicates they will be reduced with ``&``:

.. altair-plot::

chart.transform_filter(~between_1950_60 & (alt.datum.age <= 70))
chart.transform_filter(datum.year > 1980, datum.age != 90)

Using keyword-argument ``constraints`` can simplify our first example in :ref:`filter-expression`:

.. altair-plot::

alt.Chart(source).mark_area().encode(
x="age:O",
y="people:Q",
).transform_filter(year=2000, sex=1)

Transform Options
^^^^^^^^^^^^^^^^^
Expand Down

0 comments on commit 3efc144

Please sign in to comment.