Question with the result of the move function in DolphinDB

16 Views Asked by At
x=3 9 5 1 4 9;
index = (second(08:20:00)+1..4) join 08:21:01 join 08:21:02
x = index.indexedSeries(x)
move(x,3s)

Why does the move function return 1 for timestamps 8:21:01 and 8:21:02, shouldn't it return 9 and 5? enter image description here

1

There are 1 best solutions below

0
jinwandalaohu On

The calculation rules of the move function are similar to that of tmove. For each element Ti in T, return the element in X which is at the same position as (Ti - window) in T. If there is no match of (Ti - window) in T, return the corresponding element in X at the previous adjacent time of (Ti - window). For details, please refer to tmove — DolphinDB 1.30 documentation.

In your script, as there is no match of 08:20:58 (08:21:01 - 3s) and 08:20:59 (08:21:02 - 3s) in index, the corresponding element in x at the previous adjacent time (08:20:04) is returned.

T = (second(08:20:00)+1..4) join 08:21:01 join 08:21:02
X = 3 9 5 1 4 9
m = table(T as t,X as x)
select *, tmove(t, x, 3s) from m
// output
t       x       tmove_t
08:20:01    3   
08:20:02    9   
08:20:03    5   
08:20:04    1   3
08:21:01    4   1
08:21:02    9   1