John,

Thanks for the quick reply. Unfortunately, no, they're not indexed like that. 
The first columns are actually floating-point date numbers from 
matplotlib.dates.date2num. Looks like this is just going to be painful...

Thanks for the tip though. That'll definitely be useful elsewhere.
-paul

From: [email protected] 
[mailto:[email protected]] On Behalf Of John Salvatier
Sent: Wednesday, August 04, 2010 5:34 PM
To: Discussion of Numerical Python
Subject: Re: [Numpy-discussion] Quick array value assignment based on common 
values

Are they numbered like that? If so you can index into the first array by the 
second one.
x[y[:,0], 1] if you can't get them into an indexable format, I think it's going 
to be slow no matter how you do it.
On Wed, Aug 4, 2010 at 4:59 PM, 
<[email protected]<mailto:[email protected]>> wrote:
Hey folks,

I've one array, x, that you could define as follows:
[[1, 2.25],
 [2, 2.50],
 [3, 2.25],
 [4, 0.00],
 [8, 0.00],
 [9, 2.75]]

Then my second array, y, is:
[[1, 0.00],
 [2, 0.00],
 [3, 0.00],
 [4, 0.00],
 [5, 0.00],
 [6, 0.00],
 [7, 0.00],
 [8, 0.00],
 [9, 0.00],
 [10,0.00]]

Is there a concise, Numpythonic way to copy the values of x[:,1] over to y[:,1] 
where x[:,0] = y[:,0]? Resulting in, z:
[[1, 2.25],
 [2, 2.50],
 [3, 2.25],
 [4, 0.00],
 [5, 0.00],
 [6, 0.00],
 [7, 0.00],
 [8, 0.00],
 [9, 2.75],
 [10,0.00]]

My current task has len(x) = 25000 and len(y) = 350000 and looping through is 
quite slow unfortunately.

Many thanks,
-paul


_______________________________________________
NumPy-Discussion mailing list
[email protected]<mailto:[email protected]>
http://mail.scipy.org/mailman/listinfo/numpy-discussion

_______________________________________________
NumPy-Discussion mailing list
[email protected]
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to