# [SciPy-User] [SciPy-user] Matching up arrays?

mdekauwe mdekauwe@gmail....
Thu Nov 18 23:58:07 CST 2010

```Hi,

So I have 2 arrays which hold some data and for each array I have an array
with the associated date stamp. The dates vary between arrays, so what I
would like to be able to do is just subset the data so I end up with two
arrays if there is a matching time stamp between arrays (with the idea being
I would do some comparative stats on these arrays). How I solved it seems a
bit ugly and I wondered if anyone had a better idea?

e.g.

m_date = np.array(['1998-01-01 00:00:00', '1999-01-01 00:00:00', '2000-01-01
00:00:00',
'2005-01-01 00:00:00'])
o_date = np.array(['1998-01-01 00:00:00', '1999-01-01 00:00:00', '2000-01-01
00:00:00'])

mm = np.array([ 3.5732, 4.5761, 4.0994, 3.9031])
oo = np.array([ 5.84, 5.66, 5.83])

x, y = [], []
o = np.vstack((o_date, oo))
m = np.vstack((m_date, mm))
for i in xrange(o.shape[1]):
for j in xrange(m.shape[1]):
if m[0,j] == o[0,i]:
x.append(m[1,j])
y.append(o[1,i])

thanks

Martin

--
View this message in context: http://old.nabble.com/Matching-up-arrays--tp30254994p30254994.html
Sent from the Scipy-User mailing list archive at Nabble.com.

```