Numpy: Vectorize len



examples/numpy/vectorize_len.py
import numpy as np

animals = np.array(['Cow', 'Elephant', 'Snake', 'Camel', 'Praying Mantis'])
print(animals)

vlen = np.vectorize(len)
print(vlen(animals))

['Cow' 'Elephant' 'Snake' 'Camel' 'Praying Mantis']
[ 3  8  5  5 14]