Reputation: 515
I want to append 10 numpy arrays one after another. Is there any functions like
vm_all = np.concatenate(vm_1,vm_2,vm_3,vm_4,vm_5,vm_6,vm_7,vm_8,vm_9,vm_10)
or
cre_all = np.append(cre_1,cre_2,cre_3,cre_5,cre_6,cre_7,cre_8,cre_9,cre_10)
The problem with append()
is that it takes at most 3 arguments. And concatenate()
takes at most 2 arguments.
We can archive the target with for
loop. But I would like to know whether any function available for this.
Upvotes: 1
Views: 1821
Reputation: 8709
This will work for you:
vm_all = np.concatenate((vm_1,vm_2,vm_3,vm_4,vm_5,vm_6,vm_7,vm_8,vm_9,vm_10))
Upvotes: 2
Reputation: 31349
I think you are looking for hstack
import numpy as np
vm_all = np.hstack([vm_1,vm_2,vm_3,vm_4,vm_5,vm_6,vm_7,vm_8,vm_9,vm_10])
There is also vstack if you want to concatenate along the vertical axis.
Concatenate works as well, but you have to give a sequence of your arrays.
import numpy as np
vm_all = np.concatenate([vm_1,vm_2,vm_3,vm_4,vm_5,vm_6,vm_7,vm_8,vm_9,vm_10])
Upvotes: 2