description |
---|
Speed up your workflow! |
PyStreamAPI presents four distinct groups of conditions for your convenience. Within these groups, you'll find a variety of conditions with varying parameters. For instance, certain conditions like even()
do not require any parameters, while others such as less_than(n)
involve specifying a single parameter.
Moreover, PyStreamAPI provides a single combiner that empowers you to seamlessly merge multiple conditions, thereby enhancing your ability to manipulate data more effectively.
All conditions can be imported from:
from pystreamapi.conditions import …
In order to import all conditions from a specific group, use these imports:
from pystreamapi.conditions.numeric import *
from pystreamapi.conditions.types import *
from pystreamapi.conditions.string import *
from pystreamapi.conditions.date import *
{% content-ref url="type-conditions.md" %} type-conditions.md {% endcontent-ref %}
{% content-ref url="numeric-conditions.md" %} numeric-conditions.md {% endcontent-ref %}
{% content-ref url="string-conditions.md" %} string-conditions.md {% endcontent-ref %}
{% content-ref url="date-conditions.md" %} date-conditions.md {% endcontent-ref %}
one_of(*conditions)
checks if one of the given conditions are fulfilled. You can pass as many conditions as you want.
from pystreamapi import Stream
from pystreamapi.conditions import prime, even, one_of
Stream.of([1, 2, 3, 4, 5]) \
.filter(one_of(even(), prime())) \
.for_each(print)