Combine all elements of two arrays python -
i have 2 arrays, , want combine ith elements in each 1 together:
import numpy np = np.array(['a', 'b', 'c']) b = np.array(['x', 'y', 'z'])
i want return
array(['ax', 'by', 'cz'])
what function this? thx,
>>> import numpy np >>> = np.array(['a', 'b', 'c']) >>> b = np.array(['x', 'y', 'z']) >>> c = np.array([i+j i, j in zip(a, b)]) >>> c array(['ax', 'by', 'cz'], dtype='|s2')
@dsm makes point if a
, b
had dtype=object
add 2 arrays together:
>>> = np.array(["a", "b", "c"], dtype=object) >>> b = np.array(["x", "y", "z"], dtype=object) >>> c = + b >>> c array([ax, by, cz], dtype=object)
Comments
Post a Comment