This Python 3.8 code snippet:
a = np.array([[1, 2], [3, 4]])
b = np.array([[5, 6]])
a = np.concatenate((a, b), axis=0)
print(a)
produces:
[[1 2]
[3 4]
[5 6]]
as expected. How do I define an empty array e
, such that this code produces the same result:
# define en empty array e here
a = np.array([[1, 2], [3, 4]])
b = np.array([[5, 6]])
e = np.concatenate((e, a), axis=0)
e = np.concatenate((e, b), axis=0)
print(e)
The use case here is an algorithm, which starts with an empty array and concatenates additional arrays to it in a loop.