I am not fat
2017-04-05 12:19:36 UTC
How do i concatenate a numpy array into a list position with an empty
np.array. I tried something like this, but for some reason i can't index the
list like this..
I tried this...
Example:
import numpy as np
nano_train_input = []
for i in range(974):
nano_train_input.append(np.random.random((78,72,3)))
input_train = [np.empty((0,78,3)) for i in range(72)]
#print nano_train_input.shape
for train in nano_train_input:
for (index,row) in zip(input_train,train.reshape(72,78,3)):
index = np.concatenate(index,[row]) # Error here
but this gives me this error message: test_min.py
<http://numpy-discussion.10968.n7.nabble.com/file/n44165/test_min.py>
Traceback (most recent call last):
File "test_min.py", line 12, in <module>
index = np.concatenate(index,[row])
TypeError: 'list' object cannot be interpreted as an index
What my desired output:
The desired output (input_train) is a list with 72 numpy.ndarraysin which,
each row from each numpy.ndarray in the list of numpy.ndarrays
(nano_train_input) is concatenated.
So example: input_train[0] would be a numpy.ndarray with dimension
(974,78,3). it should contain all first rows of the numpy.ndarrays stored
in nano_train_input
--
View this message in context: http://numpy-discussion.10968.n7.nabble.com/How-do-I-concat-a-numpy-ndarray-into-a-list-with-numpy-ndarrays-tp44165.html
Sent from the Numpy-discussion mailing list archive at Nabble.com.
np.array. I tried something like this, but for some reason i can't index the
list like this..
I tried this...
Example:
import numpy as np
nano_train_input = []
for i in range(974):
nano_train_input.append(np.random.random((78,72,3)))
input_train = [np.empty((0,78,3)) for i in range(72)]
#print nano_train_input.shape
for train in nano_train_input:
for (index,row) in zip(input_train,train.reshape(72,78,3)):
index = np.concatenate(index,[row]) # Error here
but this gives me this error message: test_min.py
<http://numpy-discussion.10968.n7.nabble.com/file/n44165/test_min.py>
Traceback (most recent call last):
File "test_min.py", line 12, in <module>
index = np.concatenate(index,[row])
TypeError: 'list' object cannot be interpreted as an index
What my desired output:
The desired output (input_train) is a list with 72 numpy.ndarraysin which,
each row from each numpy.ndarray in the list of numpy.ndarrays
(nano_train_input) is concatenated.
So example: input_train[0] would be a numpy.ndarray with dimension
(974,78,3). it should contain all first rows of the numpy.ndarrays stored
in nano_train_input
--
View this message in context: http://numpy-discussion.10968.n7.nabble.com/How-do-I-concat-a-numpy-ndarray-into-a-list-with-numpy-ndarrays-tp44165.html
Sent from the Numpy-discussion mailing list archive at Nabble.com.