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)
<ipython-input-145-74f701246da9>in<module>()
---->1 z_list = np.stack ([z_list, z1])
~/.pyenv/versions/3.6.1/lib/python3.6/site-packages/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
- i want to initialize a string with python numpy
- (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
- python - i want to speed up the calculation of for statements with numpy
- how to make a multidimensional array extracted by python
- python - read the multidimensional array saved by csv
- python - i get an error when multiplying a matrix numpy
- python - i want to search the value of the first column from two two-dimensional arrays with numpy, extract the row if the colum
- python - how to assign a multidimensional array
- i want to change the value of an element of a multidimensional array in python
- python - i want to assign a trigonometric function in a numpy matrix
- python error (about arrays)
- python - i want to calculate matrix calculation with numpy for statement with numpydot
Trends
Please follow the flow of joining the list once.