📖 INDEX
LOADING ENGINE...
np.where()
AI & DATA SCIENCE // np-where
Returns elements chosen from x or y depending on condition.
Syntax
res = np.where(arr > 5, arr, -1)Examples
Example 01Basic Usage
res = np.where(arr > 5, arr, -1)Best Practices
- Refer to the official NumPy documentation for deep vectorization techniques.
- Avoid writing custom Python for-loops for operations that can be vectorized with NumPy.