I want create 3d array with unknown length and append to the array as follows:
a = np.array([])
for n in range(1,3):
data=np.full((2,3),n)
a = np.append(a,data,axis=0)
print(a)
The expected output is:
[[[1,1,1]
[1,1,1]]
[[2,2,2]
[2,2,2]]]
However, I got an error:
ValueError: all the input arrays must have same number of dimensions, but the array at index 0 has 1 dimension(s) and the array at index 1 has 2 dimension(s)
How to declare an empty 3d numpy array with unknown length and append to it?