I would like to fill a 3D numpy array which has dimension (?, 100, 100). The first dimension will range between 500 and 1000 but is not known beforehand. I could use the append method, but this is slow.
Is there another posibility to create such a 3D numpy array where the first dimension is not known beforehand? The numpy array is filled using a for loop.
Second, let's assume I have the following two numpy arrays:
import numpy as np
arr1 = np.random.randint(0, 100, size=(30, 100, 100))
arr2 = np.random.randint(0, 100, size=(50, 100, 100))
How can I concatenate arr1 and arr2 along the first dimension so that the resulting array has shape (80, 100, 100)?
np.concatenate((arr1, arr2), axis=0)list.append. Then do oneconcatenate(or maybevstackorstack) at the end.np.stackuses a new dimension.