Reputation: 263
I have two numpy arrays. I want to append then along zero axis. If I use np.append command it demands two arguments. Whereas the following code loads first array and then second array. How I can implement np.append command in this case? I read different commands like np.concatenate and np.vstack but I don't know how to implement it in for loop. Can someone please guide me about this.
`list=[1,2]
for i in list:
s=np.load("%s.npy"%i)
r=np.append(s,axis=0)
print(s)
print(s.shape)`
Upvotes: 0
Views: 111
Reputation: 36757
You can load everything in a list of arrays and concatenate that list together to one array:
r = np.concatenate([np.random.rand(5, 5) for i in [1, 2]], axis=0)
Upvotes: 0