タイムスタンプを使用して重複行を削除するこんにちは、
TimeStamp、Tool列を使用して、データセット内の重複行を削除しようとしているサンプルデータテーブルが添付されています。
複製の基準:
同じツールで6分以内のタイムスタンプは重複と見なされ、それらの行を削除する必要があります。
JSLでこれを実現する方法を誰かが手伝ってもらえますか?
ありがとう!
@txnelson
分析データ表スクリプティングウィンドウズ再:タイムスタンプを使用して重複行を削除しますこれにより、問題の進め方の例が得られると思います。
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++;
);
再:タイムスタンプを使用して重複行を削除しますやあ@ 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));
それがあなたのために働くかどうか私たちに知らせてください。
再:タイムスタンプを使用して重複行を削除しますこんにちはロン、
私はあなたの解決策を試しましたが、結果に問題があります。
コードを実行した結果を添付しました。 なんらかの理由で重複したエントリをいくつかキャッチしていないようです。
ありがとう。
Re:タイムスタンプを使用して重複行を削除しますこれはうまくいきます、ありがとう!