Home>
I want to do something like listing a multidimensional array with numpy.
arr_list = np.array ([])
for k in range (3):
data = randint (20, 20, 80)
# 20x4 matrix
arr = data.reshape (20, 4)
arr_list = np.stack ([arr_list, arr])
After executing the above code,
ValueError Traceback (most recent call last)
<ipythoninput14574f701246da9>in<module>()
>1 z_list = np.stack ([z_list, z1])
~/.pyenv/versions/3.6.1/lib/python3.6/sitepackages/numpy/core/shape_base.py in stack (arrays, axis, out)
414 shapes = {arr.shape for arr in arrays}
415 if len (shapes)! = 1:
>416 raise ValueError ('all input arrays must have the same shape')
417
418 result_ndim = arrays [0] .ndim + 1
ValueError: all input arrays must have the same shape
Np.stack could not be used with an empty array.
I want to list a 20x4 matrix so that it looks like arr_list.shape (3, 20, 4).
If arr_list [0] is specified, the ideal mechanism is to extract the first created matrix.
How can it be realized?

Answer # 1
Related articles
 numpy  [python] i want to combine alternately and make two sets of two arrays of latitude and longitude
 python  i want to speed up the calculation of for statements with numpy
 python  algorithm to extract numpy serial numbers
 python  about numpy genfromtxt
 i want to sort multiple arrays at the same time in python
 python  i want to move an element of a numpy array by referring to another array
 python  why is numpy working without importing numpy?
 python  i want to take the nth to mth slices in a numpy array sometimes n is positive and sometimes it is negative
 python i want to convert a multidimensional array back to an image
 python  i want to calculate matrix calculation with numpy for statement with numpydot
 (python) i would like to know how to combine an int value and a multidimensional array
 python  how to make a multidimensional array by for statement and multiplication
 python 3x  how to remove 0 elements in numpy 2darray
 python  the values of other arrays change with the array
 python  i have numpy installed, but i get an error saying "exp: unknown"
 python  numpy import
 python  i want to store a 3d array in an array using numpy
 about php multidimensional arrays
Trends
 php  coincheck api authentication doesn't work
 php  i would like to introduce the coincheck api so that i can make payments with bitcoin on my ec site
 [php] i want to get account information using coincheck api
 python  you may need to restart the kernel to use updated packages error
 python 3x  typeerror: 'method' object is not subscriptable
 the emulator process for avd pixel_2_api_29 was killed occurred when the android studio emulator was started, so i would like to
 javascript  how to check if an element exists in puppeteer
 xcode  pod install [!] no `podfile 'found in the project directory
 vuejs  [vuetify] unable to locate target [dataapp] i want to unit test to avoid warning
 android studio  unresolved reference comes out in kotlin
Please follow the flow of joining the list once.