[Numpy-discussion] Overlapping time series

Andreas Hilboll lists at hilboll.de
Tue Feb 11 08:41:38 EST 2014


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.

HTH,
Andreas.



More information about the NumPy-Discussion mailing list