otp.ops.sametime_as_existing#
- sametime_as_existing(left_time, right_time, delay_msec)#
If
delay_msecis positive, it returns True for a tick from the passed left time series and the latest tick from the passed right time series that arrived at least bydelay_msecbefore the tick from the left time series.If
delay_msecis negative, it returns True for a tick from the passed left time series and the latest tick from the passed right time series that arrived at mostdelay_msecafter the tick from the left time series; that is, the latest tick from the interval(-Inf, t1 + |delay_msec|], wheret1is the timestamp of the tick from the left time series.Can be used only in the
onparameter ofonetick.py.join().- Parameters:
- Return type:
Examples
Join each tick from the left source with the latest tick from the right source that arrived at least 2 milliseconds before it:
>>> left = otp.Ticks(A=[1, 2, 3], offset=[3, 5, 7]) >>> right = otp.Ticks(B=[10, 20, 30, 40], offset=[0, 2, 4, 6]) >>> data = otp.join(left, right, on=otp.ops.sametime_as_existing(left['TIMESTAMP'], right['TIMESTAMP'], 2)) >>> otp.run(data) Time A B 0 2003-12-01 00:00:00.003 1 10 1 2003-12-01 00:00:00.005 2 20 2 2003-12-01 00:00:00.007 3 30
With negative delay ticks from the right source that arrived less than 2 milliseconds after the tick from the left source are also considered:
>>> data = otp.join(left, right, on=otp.ops.sametime_as_existing(left['TIMESTAMP'], right['TIMESTAMP'], -2)) >>> otp.run(data) Time A B 0 2003-12-01 00:00:00.003 1 30 1 2003-12-01 00:00:00.005 2 40 2 2003-12-01 00:00:00.007 3 40
See also
SAMETIME_AS_EXISTING OneTick functionJOIN OneTick event processor