Which
Generated from the engine's own definition: compute-engine's symbol, which we neither extend nor document by hand. No examples yet — the crosswalk is the reason it has a page.
Which(c1, e1, c2, e2, …) evaluates to the value of the first e whose condition c is True, and to Missing when no condition is True. A last clause with the condition True is the default. Only the selected expression is evaluated.
Element-wise selection: when a condition is a flat list of booleans (L < 3 with L a list), the selection is made at each position, as numpy.select does, and the value is a list. At each position, the first clause whose condition is True there gives the value: an expression that is a list gives its element at that position, any other expression gives its own value. With L = [1, 3, 5], Which(L < 2, 10, L < 4, L, True, 0) is [10, 3, 0].
- A condition that is not a list applies to every position.
- Every expression is a number, a point, or a flat list of numbers or of points with the length of the condition, and all have one kind. A nested list, a list of another length, a string and a list of strings are static errors, as is a condition that is a nested list or holds a Missing cell. A relation (a boolean) is accepted.
- A position that no clause selects holds NaN for a number, a point whose coordinates are NaN for a point, and Missing for a boolean.
Which(expression+) -> unknownas compute-engine declares itTyped signatures
| Type | Package | Applies |
|---|---|---|
(expression+) -> unknown | compute-engine | always |