취소
다음에 대한 결과 표시 
표시  만  | 다음에 대한 검색 
다음을 의미합니까? 
The Discovery Summit 2025 Call for Content is open! Submit an abstract today to present at our premier analytics conference.
See how to use to use Text Explorer to glean valuable information from text data at April 25 webinar.
언어 선택 변환 막대 숨기기
게시된 스레드 원본 보기

타임스탬프를 사용하여 중복 행 제거

psundar6
Level III

안녕하세요,

 

TimeStamp,Tool 열을 사용하여 데이터 세트 내의 중복 행을 제거하려는 샘플 데이터 테이블이 첨부되어 있습니다.

복제 기준:

동일한 도구에서 6분 이내의 타임스탬프는 중복으로 간주되며 해당 행을 제거해야 합니다.

누군가 JSL에서 이것이 어떻게 달성될 수 있는지 도와줄 수 있습니까?

 

감사해요!

 

@txnelson

원래 English (US) 로 작성된 이 게시물은 귀하의 편의를 위해 번역되었습니다. 답장을 보내면 English (US) 로 다시 번역됩니다.

2 채택된 솔루션

채택된 솔루션
txnelson
Super User

Re: 타임스탬프를 사용하여 중복 행을 제거합니다.

이것이 문제를 진행하는 방법에 대한 예가 될 것이라고 믿습니다.

Names Default To Here( 1 );
dt = Current Data Table();

// Loop through the data table deleting all duplicate rows
i = 1;
While( i <= N Rows( dt ),
 
 // Find the upper and lower bounds to match on
 lower = :timeStamp[i] - In Minutes( 6 );
 upper = :timeStamp[i] + In Minutes( 6 );
 
 // Find the rows that match
 theRows = dt << get rows where( :timeStamp > lower & :timeStamp < upper );
 
 // Remove the current row from the list.  We do not want to delete it
 Try( theRows[1] = [] );
 
 // Delete the remaining rows
 Try( dt << delete rows( theRows ) );
 
 // Increment the row to work on
 i++;
);
ron_horne
Super User (Alumni)

Re: 타임스탬프를 사용하여 중복 행을 제거합니다.

안녕 @psundar6 ,

@txnelson 아주 좋은 솔루션을 제공합니다.

테이블 정렬 및 열 수식을 사용하는 대체 접근 방식은 대화형으로 수행하거나 다음과 같이 스크립팅하여 수행할 수 있습니다.

dt = current data table();

dt << Sort(
 By( :TimeStamp, :Tool ),
 Replace Table,
 Order( Ascending, Ascending )
);

dt << New Column( "to delete",
 Numeric,
 "Ordinal",
 Format( "Best", 12 ),
 Formula( If( :Tool == Lag( :Tool, 1 ) & Date Difference( Lag( :TimeStamp, 1 ), :TimeStamp, "Minute" ) < 6, 1, 0 ), eval formula )
);
dt:to delete << suppress eval(true);

dt<< delete rows (dt<< get rows where (:to delete == 1));

그것이 당신에게 효과가 있는지 알려주세요.

5 응답 5
txnelson
Super User

Re: 타임스탬프를 사용하여 중복 행을 제거합니다.

이것이 문제를 진행하는 방법에 대한 예가 될 것이라고 믿습니다.

Names Default To Here( 1 );
dt = Current Data Table();

// Loop through the data table deleting all duplicate rows
i = 1;
While( i <= N Rows( dt ),
 
 // Find the upper and lower bounds to match on
 lower = :timeStamp[i] - In Minutes( 6 );
 upper = :timeStamp[i] + In Minutes( 6 );
 
 // Find the rows that match
 theRows = dt << get rows where( :timeStamp > lower & :timeStamp < upper );
 
 // Remove the current row from the list.  We do not want to delete it
 Try( theRows[1] = [] );
 
 // Delete the remaining rows
 Try( dt << delete rows( theRows ) );
 
 // Increment the row to work on
 i++;
);

원래 English (US) 로 작성된 이 게시물은 귀하의 편의를 위해 번역되었습니다. 답장을 보내면 English (US) 로 다시 번역됩니다.

psundar6
Level III

Re: 타임스탬프를 사용하여 중복 행을 제거합니다.

작동합니다. 감사합니다!

원래 English (US) 로 작성된 이 게시물은 귀하의 편의를 위해 번역되었습니다. 답장을 보내면 English (US) 로 다시 번역됩니다.

ron_horne
Super User (Alumni)

Re: 타임스탬프를 사용하여 중복 행을 제거합니다.

안녕 @psundar6 ,

@txnelson 아주 좋은 솔루션을 제공합니다.

테이블 정렬 및 열 수식을 사용하는 대체 접근 방식은 대화형으로 수행하거나 다음과 같이 스크립팅하여 수행할 수 있습니다.

dt = current data table();

dt << Sort(
 By( :TimeStamp, :Tool ),
 Replace Table,
 Order( Ascending, Ascending )
);

dt << New Column( "to delete",
 Numeric,
 "Ordinal",
 Format( "Best", 12 ),
 Formula( If( :Tool == Lag( :Tool, 1 ) & Date Difference( Lag( :TimeStamp, 1 ), :TimeStamp, "Minute" ) < 6, 1, 0 ), eval formula )
);
dt:to delete << suppress eval(true);

dt<< delete rows (dt<< get rows where (:to delete == 1));

그것이 당신에게 효과가 있는지 알려주세요.

원래 English (US) 로 작성된 이 게시물은 귀하의 편의를 위해 번역되었습니다. 답장을 보내면 English (US) 로 다시 번역됩니다.

psundar6
Level III

Re: 타임스탬프를 사용하여 중복 행을 제거합니다.

안녕하세요 론,

귀하의 솔루션을 시도한 결과 결과에 문제가 있습니다.

귀하의 코드를 실행한 결과를 첨부했습니다. 어떤 이유로 중복된 항목을 두 개 포착하지 못하는 것 같습니다.

감사해요.

원래 English (US) 로 작성된 이 게시물은 귀하의 편의를 위해 번역되었습니다. 답장을 보내면 English (US) 로 다시 번역됩니다.

ron_horne
Super User (Alumni)

Re: 타임스탬프를 사용하여 중복 행을 제거합니다.

감사해요 @psundar6 나에게 알려줘서. 오타가 있어서 지금 수정했습니다..

원래 English (US) 로 작성된 이 게시물은 귀하의 편의를 위해 번역되었습니다. 답장을 보내면 English (US) 로 다시 번역됩니다.