Numpy: Vectorize len
- vectorize
- len
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]