Expr と名前 Exprこんにちは、
350,000 行という大量のデータを分析しています。
コードは行ごとにループを実行してテーブル 1 とテーブル 2 の間の一意のデルタを計算し、そのデルタをメイン データ テーブルの列に追加します。 以下のコードで何かが正しくありません。 なにか提案を?
Names Default To Here( 1 );
dt1 = Data Table( "dt_ref" );
dt2 = Data Table( "Data table" );
digt = 5;
itsel1 = {"Currents A", "Currents A2", "Currents A3", "Currents A4", "Currents A5"}; //List of columns to align.<BR />
//// Loop to calculate the delta between the dt1 and dt2 and the add the delta to the column of dt2 from the itsel1 list
dt2 << Add Row( 1, At Start );
dt2 << Begin Data Update;
For Each( {element, idx}, itsel1,
Eval(
Eval Expr(
Column( dt2, element ) << Set Each Value(
Expr(
Name Expr( Column( dt2, element ) )
),
Expr(
Num(
Substr( Char( Column( dt1, "Median" )[dt1 << get rows where( :Tests == element )] - Column( dt2, element ) ), 1, digt + 1 )
) + Column( dt2, element )
)
)
)
)
);
dt2 << Delete Row( 1 );
dt2 << End Data Update;
ありがとう、
ジャッキー
自動化とスクリプト作成Re: Expr と Name Exprここでどのような種類の計算を実行しているのかわかりません
Num(Substr(Char(Column(dt1, "Median")[dt1 << get rows where(:Tests == element)] - Column(dt2, element)), 1, digt + 1)) + Column(dt2, element)
しかし、このようなことがあなたを助けるかもしれません
Names Default To Here(1);
dt1 = Open("$DOWNLOADS/dt_ref.jmp");
dt2 = Open("$DOWNLOADS/Data table.jmp");
digt = 5;
itsel1 = {"Currents A", "Currents A2", "Currents A3", "Currents A4", "Currents A5"}; //List of columns to align.
dt2_colnames = dt2 << Get Column Names("String");
//// Loop to calculate the delta between the dt1 and dt2 and the add the delta to the column of dt2 from the itsel1 list
For Each({colname}, itsel1,
dt2_col_idx = Contains(dt2_colnames, colname);
If(dt2_col_idx == 0,
Print("Skipped column: " || colname);
continue(); // skip this column
);
dt1_row_idx = Loc(dt1[0, "Tests"], colname);
If(N Items(dt1_row_idx) == 0,
Print("Skipped row: " || colname);
continue();
,
dt1_row_idx = dt1_row_idx[1];
);
dt2[0, dt2_col_idx] = dt2[0, dt2_col_idx] - dt1[dt1_row_idx, "Median"];
);Re: Expr と Name Exprそこで、dt2のデータをdt1のTestの中央値と揃えようとしています。
したがって、現在の A1 の中央値は 5.408 であるため、dt2 の現在の A1 の各行を減算し、それを dt2 の現在の A1 の行の値に戻します。
5.408 - 2.4963333333 = 2.912
2.912 + 2.496333333 = 5.40。 100 万行の巨大なデータセットがあるため、従来の for ループを避けています。Expr の方が高速です。

Re: Expr と Name Expr値を四捨五入しないと、中央値だけになってしまいませんか?
x = 中央値、
y = 行の値、
z = 結果
x - y = z
z + y = x?
Re: Expr と Name Expr@jthiそれは正しいのですが、「z」を小数点第 2 位に四捨五入してから y に戻したいのです。 この理由は「テスターデータとマスターデータをオフセットする」ためです。