[Numpy-discussion] Overlapping time series

Joris Van den Bossche jorisvandenbossche at gmail.com
Tue Feb 11 09:41:00 EST 2014


2014-02-11 14:55 GMT+01:00 Andreas Hilboll <lists at hilboll.de>:

> On 11.02.2014 14:47, Daniele Nicolodi wrote:
> > On 11/02/2014 14:41, Andreas Hilboll wrote:
> >> On 11.02.2014 14:22, Daniele Nicolodi wrote:
> >>> On 11/02/2014 14:10, Andreas Hilboll wrote:
> >>>> On 11.02.2014 14:08, Daniele Nicolodi wrote:
> >>>>> Hello,
> >>>>>
> >>>>> I have two time series (2xN dimensional arrays) recorded on the same
> >>>>> time basis, but each with it's own dead times (and start and end
> >>>>> recording times).  I would like to obtain two time series containing
> >>>>> only the time overlapping segments of the data.
> >>>>>
> >>>>> Does numpy or scipy offer something that may help in this?
> >>>>>
> >>>>> I can imagine strategies about how to approach the problem, but none
> >>>>> that would be efficient.  Ideas?
> >>>>
> >>>> Take a look at pandas.  It has built-in time series functionality.
> >>>
> >>> Even using Pandas (and I would like to avoid to have to depend on it)
> it
> >>> is not clear to me how I would achieve what I want.  Am I missing
> something?
> >>
> >> If the two time series are pandas.Series objects and are called s1 and
> s2:
> >>
> >>     new1 = s1.ix[s2.dropna().index].dropna()
> >>     new2 = s2.ix[s1.dropna().index].dropna()
> >>     new1 = new1.ix[s2.dropna().index].dropna()
> >>
> >> Looks hackish, so there might be a more elegant solution.  For further
> >> questions about how to use pandas, please look at the pydata mailing
> >> list or stackoverflow.
> >
> > Correct me if I'm wrong, but this assumes that missing data points are
> > represented with Nan.  In my case missing data points are just missing.
>
> pandas doesn't care.
>
> In pandas, you could simply do something like this (assuming the time is
set as the index):

pd.concat([s1, s2], axis=1)

and then remove the nan's (where the index was not overlapping) or use
`join='inner'`

Joris


> Andreas.
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20140211/7c655f91/attachment.html>


More information about the NumPy-Discussion mailing list