[Tutor] inserting a vector into an array - numpy Q
washakie
washakie at gmail.com
Tue Jun 10 23:31:13 CEST 2008
I know there must be a better way to do this with slices, but I can't seem to
figure it out - I keep getting errors about the need to have the same
dimensions:
Here's what I'm trying:
>>> type(time)
<type 'list'>
>>> type(new_data)
<type 'numpy.ndarray'>
>>> shape(time)
(1334,)
>>> shape(new_data)
(1334, 54)
>>> newArray=concatenate((time,new_data))
Traceback (most recent call last):
File "<string>", line 1, in <string>
ValueError: arrays must have same number of dimensions
>>>
I've tried transposing, setting axis=1, etc. but I'mdoing something wrong.
Here's my solution:
outList=[]
for i in range(len(time)):
tl=[time[i]]
tl.extend(new_data[i,:])
outList.append(tl)
Suggestions for improvement - or just how the heck I'm supposed to do this
in numpy are appreciated!
--
View this message in context: http://www.nabble.com/inserting-a-vector-into-an-array---numpy-Q-tp17765150p17765150.html
Sent from the Python - tutor mailing list archive at Nabble.com.
More information about the Tutor
mailing list