より速い反復こんにちは、
反復を最適化しようとしています。
各列がメイン データ テーブル列の名前である参照テーブルがあります。参照データ テーブルの各行を反復処理し、 Column(dt_ref, "Nrows")>2 & Comment[i] == "A > B" の場合、Column(dt_main, "Values") の値を参照テーブルの新しい A 列と新しい B 列に追加します。
対応する X/Y/ウェーハ ID にマップされた各タイプ A と B の最後に記録された値のみに関心があるため、連想配列を使用しています。
以下のスクリプトは非常に時間がかかります。最適化する方法はありますか?
Names Default To Here( 1 );
start = Tick Seconds();
dt_main = Data Table( "maintable" );
dt_ref = Data Table( "referencetable" );
Try( dt_ref << delete columns( :New N, :New R ) );
dt_ref << New Column( "New A", "Numeric" );
dt_ref << New Column( "New B", "Numeric" );
nrows = [];
For( nn = 1, nn <= N Rows( dt_ref ), nn++,
Insert Into( nrows, nn )
);
dt_ref << begin data update;
For Each( {r, i}, nrows,
If( dt_ref:N Rows[i] > 2 & dt_ref:Comment[i] == "A > B",
/// Create AA to get the last recorded values for each A and B to the corresponding X/Y/Wafer ID from dt_main
countsessions = Associative Array(
dt_main:Type[dt_main << get rows where( dt_main:X Coord == dt_ref:X Coord[i] & dt_main:Y Coord == dt_ref:Y Coord[i] & dt_main:Wafer ID == dt_ref:Wafer ID[i] )],
dt_main:Value[dt_main << get rows where( dt_main:X Coord == dt_ref:X Coord[i] & dt_main:Y Coord == dt_ref:Y Coord[i] & dt_main:Wafer ID == dt_ref:Wafer ID[i] )];
);
Try( dt_ref:New A[i] = countsessions["A"] );
Try( dt_ref:New B[i] = countsessions["B"] );
)
);
dt_ref << end data update;
end = Tick Seconds();
Show( Char( end - start ) );
自動化とスクリプトRe: より高速な反復私は、組み込みの JMP 選択、結合、分割、更新プラットフォームを使用して、別の方法を採用しました。これは非常に高速に動作し、参照テーブル内の A>B 行に欠損値がある点を除いて、同じ結果が得られたようです...ただし、私が得た値は N(A) 列と N(b) 列と一致します。したがって、私の考えは完全に的外れかもしれません。
Names Default To Here( 1 );
start = Tick Seconds();
dt_main = Data Table( "maintable" );
dt_ref = Data Table( "referencetable" );
Try( dt_ref << delete columns( :New A, :New B ) );
// Create a subset of the maintable that contains only data for the rows in
// the reference table that have comment value of A>B
// Select only A>B rows in reference table
dt_ref << select where(:Comment == "A > B");
dtAB = dt_ref<<SUBSET>0, dtMainJoin << delete rows);
dtMainJoin = dtMainJoin << sort(by(:RowNum), Order(ascending), Replace table(1));
dtMainJoin << delete columns(:RowNum);
// Split the table to create the New A and New B Columns
dtSplit = dtMainJoin <<
Split(
Split By( :Type ),
Split( :Value ),
Group( :X Coord, :Y Coord, :Wafer ID ),
Output Table(
"Split of Join of maintable with Subset of referencetable 2 by Type"
),
Sort by Column Property
);
// Clean up dtMainJoin table by closing it
close(dtMainJoin, nosave);
// Rename the A and B columns
dtSplit:A << set name("New A");
dtSplit:B << set name("New B");
// Use Update to merge the dtSplit data into the reference table
dt_ref << Update(
With(
Data Table(
dtSplit
)
),
Match Columns( :X Coord = :X Coord, :Y Coord = :Y Coord, :Wafer ID = :Wafer ID )
);
// Clean up
close( dtSplit, nosave );
dt_ref << end data update;
end = Tick Seconds();
Show( Char( end - start ) );</SUBSET>