whereΒΆ

where(
condition: ndarray[dtype = bool] | list | bool,
x: PolyArray | Poly | float | int | ndarray | list,
y: PolyArray | Poly | float | int | ndarray | list,
) PolyArray[Dim]ΒΆ

Select elements from x or y depending on condition.

Return a PolyArray broadcast-compatible with x and y, where each element is x[i] if condition[i] is True, otherwise y[i]. All of condition, x, and y are broadcast to a common shape.

Parameters:
  • condition (ndarray | list | bool) – Condition array or scalar (ndarray, list of bool, or bool). If condition is an ndarray with a numeric (int/float) dtype, it is implicitly converted to bool (non-zero elements are treated as True, matching NumPy). If condition is a list, its elements must be bool-like; numeric elements are not supported.

  • x (PolyArray | Poly | float | int | ndarray | list) – Array or scalar (PolyArray, Poly, ndarray, list, float, or int) from which to select elements where the condition is True.

  • y (PolyArray | Poly | float | int | ndarray | list) – Array or scalar (PolyArray, Poly, ndarray, list, float, or int) from which to select elements where the condition is False.

Returns:

Result PolyArray. Shape depends on broadcasting of condition, x, and y.

Return type:

PolyArray[Dim]