リスト内のすべての列の空の行を削除する解決済み: Re: JSL を使用して 1 つ以上の空の値を持つ行を削除する - ページ 2 - JMP ユーザー コミュニティ
上記の説明に基づいて、空の行を削除するスクリプトがありますが、リストされた列のいずれかが空の行を削除するように見えますが、リストされた列のすべてが空の行を削除したいと考えています。
ありがとう
// Get the current data table
dt = Current Data Table();
// Get all column names as strings
cnmes = dt << Get Column Names("string");
// Initialize Start and End indices
Start = .;
End = .;
// Find the index of the "Start" column
For(i = 1, i <= N Items(cnmes), i++,
If(Contains(cnmes[i], "Start"),
Start = i + 1;
Break(); // Exit loop once found
);
);
// Find the index of the "End" column
For(j = 1, j <= N Items(cnmes), j++,
If(Contains(cnmes[j], "End"),
End = j-1;
Break(); // Exit loop once found
);
);
datacols = {};
For(k = start, k <= End, k++,
Insert into (datacols, cnmes[k]) // Determine Data Columns
);
keeprows = Loc Nonmissing( datacols );
dt << select rows( keeprows ) << invert Row Selection << delete rows;
自動化とスクリプトRe: リスト内のすべての列の空の行を削除するJSL を十分に学習して、必要な機能が実行されない理由を理解しましたか?
スクリプトガイドの「Select Where」を参照してください。
datacols の最初の列に欠損値がある行をすべて見つけ、その行のリストから 2 列目に欠損値がある行を選択し、次に 3 列目に欠損値がある行を選択し、これを datacols リストの最後の列に達するまで繰り返します。
その後に残る行は、datacols 内のすべての列の値が欠落している行のみになります。
その後は、残りの行を削除するだけです。
Select Where() 関数の Current Selection() 要素を参照します。これにより、後続の Select Where 関数は、選択を適用するときに、以前に選択された行のみを参照するように制限されます。
Re: リスト内のすべての列の空の行を削除するジム
なるほど、なるほど。失敗するように生まれてきたのですね。でも、あなたのアイデアは素晴らしいですね!こんな感じです。
dt = Current Data Table();
// Get all column names as strings
cnmes = dt << Get Column Names("string");
// Initialize Start and End indices
Start = .;
End = .;
// Find the index of the "Start" column
For(i = 1, i <= N Items(cnmes), i++,
If(Contains(cnmes[i], "Start"),
Start = i + 1;
Break(); // Exit loop once found
);
);
// Find the index of the "End" column
For(j = 1, j <= N Items(cnmes), j++,
If(Contains(cnmes[j], "End"),
End = j-1;
Break(); // Exit loop once found
);
);
For(l = Start, l <= End, l++,
full_rows = dt << get rows where( !Is Missing( As Column(cnmes[l]) ) );
For Each Row(If(is missing(cnmes[i]), Remove From(full_rows))));
dt << Select Rows(full_rows) << Invert Row Selection << Delete Rows;Re: リスト内のすべての列の空の行を削除するこれは機能しますか? どういう仕組みなのかわかりません。各列を互いに独立して扱っています。各列のfull_rowsをリセットしています。
複数選択のwhere()_を使用して、選択したい行を絞り込む例を示します。
names default to here(1);
dt =
// Open Data Table: Big Class.jmp
// → Data Table( "Big Class" )
Open( "$SAMPLE_DATA/Big Class.jmp" );
// Select all males
dt << select where( :Sex == "M");
// From all of the selected males, select all of the 12 year olds
dt << select where( :age == 12, Current Selection("Restrict"));Re: リスト内のすべての列の空の行を削除するスクリプトの最初の部分で何が起こっているのか、またはそれがこの質問とどう関連しているのか(列のリストを作成するため?)は正確にはわかりませんが、次のことが可能です。JMP プラットフォーム(欠落データ パターン)を使用して、場所を選択する(Jim が提案したように)、またはたとえば、データ テーブルの添え字 + ループ / データ テーブルの添え字 + いくつかのマトリックス操作を使用します。
まず、JMPが提供する欠損データプラットフォームを試してみることをお勧めします。これが使えるかどうか(使えます)確認した後、Jimが提案した「Select Where」オプションを検討してみてください。スクリプトが作成でき、Jimの提案の仕組みを理解したら、もしまだご希望であれば、以下で提案するデータテーブルサブスクリプションオプションを検討してみてください。
欠損データパターン
JMPの使い方 > データの入力と編集 > データテーブルでのデータの整理 > データテーブル内の欠損データのパターンの表示
スクリプトガイド > データテーブル > 高度なデータテーブルスクリプト > 欠落データパターンの検索


これは行列演算を使用しており、動作するはずです
Names Default To Here(1);
dt = New Table("Untitled",
Add Rows(11),
Compress File When Saved(1),
New Column("Column 1", Character, "Nominal", Set Values({"", "", "aa", "", "a", "a", "", "a", "", "a", ""})),
New Column("Column 2", Character, "Nominal", Set Values({"", "a", "a", "a", "a", "", "", "a", "a", "", ""})),
New Column("Column 3", Character, "Nominal", Set Values({"a", "", "a", "", "a", "", "a", "", "", "", "a"}))
);
cols_to_check = {"Column 2", "Column 3"};
m = Matrix(IsMissing(dt[0, cols_to_check]));
rows_to_delete = Loc(V Sum(m`) == 2);
dt << select rows(rows_to_delete); // for demo purposes
dt << Delete Rows(rows_to_delete); // use this in real use case
これは、欠損値をチェックしながら行をループします。
rows_to_delete = {};
For Each Row(dt,
m = Loc Nonmissing(dt[Row(), cols_to_check]);
If(N Items(m) == 0,
Insert Into(rows_to_delete, Row());
);
);
dt << Select Rows(rows_to_delete);
Re: リスト内のすべての列の空の行を削除する欠落している(リスト)と欠落している(マトリックス)
いいですね! - そして予想外でした。


どの JSL 関数を「ベクトル化」できるかについての一般的な概要はありますか?
Re: リスト内のすべての列の空の行を削除するスクリプトは動作すると思っていましたが、ご指摘の通り欠陥があります。@Jarmoのアイデアを試してみましたが、動作するものの、行列にデータが入力されませんでした。
// Get the current data table
dt = Current Data Table();
// Get all column names as strings
cnmes = dt << Get Column Names("string");
// Initialize Start and End indices
Start = .;
End = .;
// Find the index of the "Device 2" column
For(i = 1, i <= N Items(cnmes), i++,
If(Contains(cnmes[i], "Device 2"),
Start = i + 1;
Break(); // Exit loop once found
);
);
// Find the index of the "Process Script" column
For(j = 1, j <= N Items(cnmes), j++,
If(Contains(cnmes[j], "start_date"),
End = j-1;
Break(); // Exit loop once found
);
);
datacols = {};
For(k = start, k <= End, k++,
Insert into (datacols, cnmes[k]) // Determine Data Columns
);
m = Matrix(IsMissing(dt[0, datacols]));
rows_to_delete = Loc(V Sum(m`) == 2);
dt << select rows(rows_to_delete); // for demo purposes
dt << Delete Rows(rows_to_delete); // use this in real use case
Re: リスト内のすべての列の空の行を削除するデータの列には探しているものが含まれていますか?また、2をデータに合わせて調整する必要があります。動的オプションの例としては、
rows_to_delete = Loc(V Sum(m`) == N Items(cols_to_check));
それは良い考えかもしれない
Re: リスト内のすべての列の空の行を削除するジャルモ
それでうまくいきました。実は2の意味が気になっていました。
ありがとう