Write a NumPy program to combine last element with first element of two given ndarray with different shapes
import numpy as np array1 = ['PHP','JS','C++'] array2 = ['Python','C#', 'NumPy'] print("Original arrays:") print(array1) print(array2) result = np.r_[array1[:-1], [array1[-1]+array2[0]], array2[1:]] print("\nAfter Combining:") print(result)
Sample Output:
Original arrays: ['PHP', 'JS', 'C++'] ['Python', 'C#', 'NumPy'] After Combining: ['PHP' 'JS' 'C++Python' 'C#' 'NumPy']
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 Output:
need an explanation for this answer? contact us directly to get an explanation for this answer