Is it possible to vectorize the calculation of the sum of a string array in numpy?
With a loop, I would do this:
import numpy as np
myarray = np.array(['a','b','c'])
mysum = ''
for i in myarray:
mysum += i
print(mysum) #result: 'abc'
For floats, one can simply use the sum function:
myarray_float = np.array([1.0,2.0,3.0])
print(myarray_float.sum()) # result: 6.0
However, this is not possibe for arrays of strings, but leads to Type error: cannot perform reduce with flexible type.