>>> np.append([[1, 2, 3], [4, 5, 6]], [[7, 8, 9]], axis=0)
array([[1, 2, 3],
[4, 5, 6],
[7, 8, 9]])
>>> np.append([[1, 2, 3], [4, 5, 6]], [7, 8, 9], axis=0)
Traceback (most recent call last):
...
ValueError: all the input arrays must have same number of dimensions, but
the array at index 0 has 2 dimension(s) and the array at index 1 has 1
dimension(s)
# welcome to softhunt.net
# Python Program illustrating
# numpy.append()
import numpy as np
#Working on 1D
arr1 = np.arange(5)
print("1D arr1 : ", arr1)
print("Shape : ", arr1.shape)
arr2 = np.arange(8, 12)
print("
1D arr2 : ", arr2)
print("Shape : ", arr2.shape)
# appending the arrays
arr3 = np.append(arr1, arr2)
print("
Appended arr3 : ", arr3)