pyarrow.compute.case_when¶
- pyarrow.compute.case_when(cond, /, *cases, memory_pool=None)¶
Choose values based on multiple conditions.
cond must be a struct of Boolean values. cases can be a mix of scalar and array arguments (of any type, but all must be the same type or castable to a common type), with either exactly one datum per child of cond, or one more cases than children of cond (in which case we have an “else” value).
Each row of the output will be the corresponding value of the first datum in cases for which the corresponding child of cond is true, or otherwise the “else” value (if given), or null.
Essentially, this implements a switch-case or if-else, if-else… statement.
- Parameters
- condArray-like or scalar-like
Argument to compute function.
- *casesArray-like or scalar-like
Argument to compute function.
- memory_pool
pyarrow.MemoryPool
, optional If not passed, will allocate memory from the default memory pool.