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
Post a Comment