Write a NumPy program to concatenate element-wise two arrays of string
import numpy as np x1 = np.array(['Python', 'PHP'], dtype=np.str) x2 = np.array([' Java', ' C++'], dtype=np.str) print("Array1:") print(x1) print("Array2:") print(x2) new_array = np.char.add(x1, x2) print("new array:") print(new_array)
Sample Input:
(['Python', 'PHP'], dtype=np.str) ([' Java', ' C++'], dtype=np.str)
Sample Output:
Array1: ['Python' 'PHP'] Array2: [' Java' ' C++'] new array: ['Python Java' 'PHP C++']
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Sample Input:
Sample Output:
need an explanation for this answer? contact us directly to get an explanation for this answer