ak.where#
Defined in awkward.operations.ak_where on line 20.
- ak.where(condition, *args, mergebool=True, highlevel=True, behavior=None, attrs=None)#
- Parameters:
condition – Array-like data (anything
ak.to_layoutrecognizes) of booleans.x – Optional array-like data (anything
ak.to_layoutrecognizes) with the same length ascondition.y – Optional array-like data (anything
ak.to_layoutrecognizes) with the same length ascondition.mergebool (bool, default is True) – If True, boolean and numeric data can be combined into the same buffer, losing information about False vs
0and True vs1; otherwise, they are kept in separate buffers with distinct types (using anak.contents.UnionArray).highlevel (bool, default is True) – If True, return an
ak.Array; otherwise, return a low-levelak.contents.Contentsubclass.behavior (None or dict) – Custom
ak.behaviorfor the output array, if high-level.attrs (None or dict) – Custom attributes for the output array, if high-level.
This function has a one-argument form,
conditionwithoutxory, and a three-argument form,condition,x, andy. In the one-argument form, it is completely equivalent to NumPy’s nonzero function.In the three-argument form, it acts as a vectorized ternary operator:
condition,x, andymust all have the same length and:output[i] = x[i] if condition[i] else y[i]
for all
i. The structure ofxandydo not need to be the same; if they are incompatible types, the output will haveak.type.UnionType.