python - Putting 2 dimensional numpy arrays into a 3 dimensional array -


i want keep adding numpy arrays array in python. let's have following arrays:

arraytotal = np.array([]) array1 = np.array([1,1,1,1,1])  array2 = np.array([2,2,2,2,2]) 

and want append array1 , array2 arraytotal. however, when use:

arraytotal.append[array1] 

it tells me:

'numpy.ndarray' object has no attribute 'append'

how can append array1 , array2 arraytotal?

you should append arrays onto regular python list , convert list numpy array @ end:

import numpy np total = [] in range(5,15):     thisarray = np.arange(i)     total.append(thisarray) total = np.asarray(total) 

that loop makes 2d array; you'd nest loops produce higher dimensional arrays.


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -