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

Pierre GM pgmdevlist@gmail....
Fri Nov 19 05:35:36 CST 2010

On Nov 19, 2010, at 6:58 AM, mdekauwe wrote:

> 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?

You could also use the scikits.timeseries package.

In a nutshell

* Merge your timestamp array with your data array into a single object (TimeSeries). In your example, the frequency would be 'A' (annual)
>>> import scikits.timeseries as ts
>>> m_s = ts.time_series(mm, dates=m_date, freq='A')
>>> o_s = ts.time_series(oo, dates=o_date, freq='A')

Set the date limits to the same values with the `align_series` function. The series will have missing values when there's no data for a particular time stamp. By checking the mask, you can find the values that fall on the same dates for both series...

Hope it'll help, don't hesitate to contact me if you need more info.

More information about the SciPy-User mailing list