Skip to content Skip to sidebar Skip to footer

Appending Numpy Array Of Arrays

I am trying to append an array to another array but its appending them as if it was just one array. What I would like to have is have each array appended on its own index, (withoug

Solution 1:

You have to reshape m in order to have two dimension with

m.reshape(-1, 1)

thus adding the second dimension. Then you could concatenate along axis=1.

np.concatenate(temp, m, axis=1)

Solution 2:

List append is much better - faster and easier to use correctly.

temp = []
for i in my_items
    m = get_item_ids(i.color)  #returns an array as [1,4,20,5,3]  (always same number of items but diff ids
    temp = m

Look at the list to see what it created. Then make an array from that:

arr = np.array(temp)
 # or `np.vstack(temp)

Post a Comment for "Appending Numpy Array Of Arrays"