내가 당신이 요구한다고 믿는 것을 진술하겠습니다.
더하기 또는 빼기 X 시간 범위 내에서 두 날짜 열을 일치시키는 방법을 알고 싶습니다.
이 올바른지?
동일한 데이터 테이블의 열이거나 데이터 테이블간에 일치 시키려고하므로 데이터를 병합 할 수 있습니까?
+/- 시간 범위 내에 둘 이상의 행이있는 경우 가장 가까운 값을 선택 하시겠습니까? 넥타이가 있다면 어떨까요?
dt = New Table( "Untitled 3",
Add Rows( 20 ),
New Column( "atime",
Numeric,
"Continuous",
Format( "ddMonyyyy h:m", 19 ),
Input Format( "ddMonyyyy h:m" ),
Formula( As Date( Random Uniform( Today() - 100000, Today() + 100000 ) ) ),
Set Display Width( 250 )
),
New Column( "closest b time",
Numeric,
"Continuous",
Format( "ddMonyyyy h:m", 19 ),
Input Format( "ddMonyyyy h:m" ),
Set Display Width( 250 )
),
New Column( "btime",
Numeric,
"Continuous",
Format( "ddMonyyyy h:m", 19 ),
Input Format( "ddMonyyyy h:m" ),
Formula( As Date( Random Uniform( Today() - 100000, Today() + 100000 ) ) ),
Set Display Width( 250 )
),
New Column( "closest a time",
Numeric,
"Continuous",
Format( "ddMonyyyy h:m", 19 ),
Input Format( "ddMonyyyy h:m" ),
Set Display Width( 250 )
)
);
dt << runformulas;
atime << deleteformula;
btime << deleteformula;
// here it is: find both backwards and forwards nearest neighbor
kdtA = KDTable( dt:atime << getvalues );
kdtB = KDTable( dt:btime << getvalues );
For( irow = 1, irow <= N Rows( dt ), irow += 1,
// look up the row of the nearest A time to this row's B time
closeA = (kdtA << knearestrows( 1, Matrix( dt:btime[irow] ) ))[1][1];
// get the actual A time from that row and keep it in this row.
dt:closest a time[irow] = dt:atime[closeA];
// flag times that are too far away
if(abs(dt:closest a time[irow]-btime[irow])>inhours(2),dt:closest a time<<COLOR cells="">inhours(2),dt:closest b time<<COLOR cells=""></COLOR></COLOR>
2 시간 이상 떨어진 이웃 근처의 적기
knearest rows 호출의 [1] [1]은 리턴 된 목록에서 첫 번째 항목 (한 요소의 행렬)을 가져온 다음 해당 요소를 스칼라 값으로 가져옵니다. 행 번호입니다.
비대칭 창이 필요한 경우이 기술은 작동하지 않습니다 (예 : B 시간이 2 시간 이내에 있어야 함) 후 시간). 2 시간 이내에 모든 행을 가져온 다음 작동하는 첫 번째 행을 선택하여 조정할 수 있습니다.