i want create 2d numpy.array knowing @ begining shape, i.e shape=2. now, want create in for loop ith 1 dimensional numpy.arrays, , add them main matrix of shape=2, i'll this:
matrix= [numpy.array 1] [numpy.array 2] ... [numpy.array n] how can achieve that? try use:
matrix = np.empty(shape=2) in np.arange(100): array = np.zeros(random_value) matrix = np.append(matrix, array) but result of print(np.shape(matrix)), after loop, like:
(some_number, ) how can append each new array in next row of matrix? thank in advance.
i suggest working list
matrix = [] in range(10): = np.ones(2) matrix.append(a) matrix = np.array(matrix) list not have downside of being copied in memory everytime use append. avoid problem described ali_m. @ end of operation convert list object numpy array.
Comments
Post a Comment