Master programming syntax, solve interactive challenges & run live code in Syntaxis Explore Arena →
menu_book Course Curriculum (NumPy) expand_more
NumPy / Broadcasting & Vectorization

vectorize() trade-offs

Learn vectorize() trade-offs in NumPy with a dedicated explanation, a concept-specific example, practical cautions, and a mastery check.

12 min read • Intermediate
numpy-024.py
python
import numpy as np
def label(x): return 'even' if x % 2 == 0 else 'odd'
wrapped = np.vectorize(label, otypes=[str])
print(wrapped(np.arange(5)))
What to watch
Content source & attribution
Original Syntaxis Content · Original Syntaxis Content