選擇含有空資料的儲存格我有一個如下表所示的表:
| 操作員 |
M型 |
描述 |
說明2 |
M1 |
M2 |
M3 |
M4 |
M5 |
M6 |
| 第415章 |
Nxyz |
熱的 |
熱清潔1 |
第415章 |
第415章 |
第415章 |
第415章 |
第415章 |
第415章 |
| 615 |
Nxyz |
乙冷 |
冷清潔 1 |
615 |
615 |
615 |
|
615 |
615 |
| 815 |
Nxyz |
熱的 |
熱清潔2 |
815 |
815 |
815 |
815 |
815 |
815 |
| 1015 |
Nxyz |
乙冷 |
冷清潔2 |
1015 |
|
1015 |
1015 |
1015 |
1015 |
| 1215 |
Nxyz |
熱的 |
熱清潔1 |
1215 |
1215 |
1215 |
1215 |
1215 |
1215 |
| 1415 |
Nxyz |
乙冷 |
冷清潔 1 |
1415 |
1415 |
1415 |
1415 |
1415 |
|
| 1615 |
Nxyz |
熱的 |
熱清潔2 |
1615 |
1615 |
1615 |
1615 |
1615 |
1615 |
| 1815 |
Nxyz |
乙冷 |
冷清潔2 |
1815 |
1815 |
1815 |
|
|
1815 |
我只想選擇空白行。 由於每次提取資料時,M1-M6 列都會有所不同,因此我無法在 JSL 腳本中使用列名稱。 我嘗試使用下面的 FOR 迴圈來選擇空資料行,但這只會選擇最後一個儲存格為空的行。
dt = Current Data Table();
nc = dt << get column names( Numeric );
For( i = 1, i <= N Items( nc ), i++,
dt <<SELECT where=""></SELECT>
最終我想讓輸出表如下所示
| 操作員 |
M型 |
描述 |
說明2 |
機器 |
| 615 |
Nxyz |
乙冷 |
冷清潔 1 |
M4 |
| 1015 |
Nxyz |
乙冷 |
冷清潔2 |
M2 |
| 1415 |
Nxyz |
乙冷 |
冷清潔 1 |
M6 |
| 1815 |
Nxyz |
乙冷 |
冷清潔2 |
M4 |
| 1815 |
Nxyz |
乙冷 |
冷清潔2 |
M5 |
這樣做的最大技巧是在不編碼(M1、M2 等...)的列名稱的情況下執行此操作,因為它們將會更改。
有任何想法嗎
自動化和腳本編寫回覆:選擇包含空資料的儲存格<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />謝謝大家......除了 Loc Nonmissing 之外一切都有效......我目前只有 JMP9(懶得升級)並且該功能在 JMP9 中不起作用......我仍然JSL新手. .....再次感謝
回覆:選擇包含空資料的儲存格MS 更靈活 - 現在讓我們看看您如何用 0 行程式碼完成它!哈哈只是為了表明在 JSL 中有多種方法可以做同樣的事情。
回覆:選擇包含空資料的儲存格如果我正確地閱讀您的訊息,我認為您實際上有兩個問題。
- 如何找到給定列集全部缺失的行。
- 如何使您的程式碼不依賴這些列的名稱及其數量。
毫不奇怪,有很多不同的方法可以做到 1。 PM羅茲,多發性硬化症和克雷格@JMP在那裡給了你一些選擇。
我再扔一張。 你可以使用缺失資料模式找到它們的實用程式。
dt = Open( "$SAMPLE_DATA\Cities.jmp" );
//delete some columns from this table to make it fit your example
dt << delete columns( "PM10", "X", "Y" );
//change name of data table to ensure this modified version doesn't get saved
//over the sample data
dt << set name( "CitiesModified" );
//I want to use the columns starting at column 9,
//so I build a list of references to them
mycols = {};
For( i = 9, i <= N Cols( dt ), i++,
Insert Into( mycols, Column( dt, i ) )
);
mdp = Dt << Missing Data Pattern( columns( Eval( mycols ) ), Output Table( "Missing Data Pattern" ) );
//The patterns columns shows the pattern of missing values
//the Missing Data Pattern data table is sorted,
//so if there are rows with all missing data
//the last row of the Missing Data Pattern data table will be all 1s.
//The Repeat() function just builds a string of 1s for as many columns as I'm working with
If( Column( mdp, "Patterns" )[N Rows( mdp )] == Repeat( "1", N Items( mycols ) ),
//The Missing Data Pattern data table is linked to the source table so selecting a row
//in it, selects all the rows that it represents in the source table
mdp << Select Rows( N Rows( mdp ) );
//now I can delete the rows in the source table
dt << delete rows;
,
Show( "No all missing rows" )
);
我試圖展示如何使此程式碼適用於任意數量的列。 在本例中,因為我需要將列列表傳遞給缺失資料模式實用程序,所以我根據列號建立了一個清單。
即使已經編寫了所有這些內容並展示瞭如何使用缺失資料模式實用程序,我認為我最喜歡的解決方案是PM羅茲的使用堆疊列。 無論如何,您確實希望最終得到堆積的數據,因此首先這樣做可以輕鬆地選擇堆積列中丟失的行並將其刪除。
dt = Open( "$SAMPLE_DATA\Cities.jmp" );
//delete some columns from this table to make it fit your example
dt << delete columns( "PM10", "X", "Y" );
//change name of data table to ensure this modified version doesn't get saved
//over the sample data
dt << set name( "CitiesModified" );
//again I need a list of columns to use in the Stack()
mycols = {};
For( i = 9, i <= N Cols( dt ), i++,
Insert Into( mycols, Column( dt, i ) )
);
//stack those columns creating a new data table
stacked_dt = dt << Stack(
columns( Eval( mycols ) ),
Source Label Column( "Gas" ),
Stacked Data Column( "PPM" )
);
missing_rows = stacked_dt << get rows where( Is Missing( :PPM ) );
stacked_dt << delete rows( missing_rows );
回覆:選擇包含空資料的儲存格選擇包含空白儲存格的行的另一種方法:
dt << select where(!Contains(Loc Nonmissing(dt << get as matrix), Row()));
回覆:選擇包含空資料的儲存格非常光滑。不知道你可以插入表達式(e)。我想插入需要一個清單。
回覆:選擇包含空資料的儲存格相同的答案PM羅茲使用表達式操作:
dt = Current Data Table();
e = Expr( Or() ); // the OR of the ismissing(columns) will be built here
nc = dt << get column names( Numeric );
For( i = 1, i <= N Items( nc ), i++,
Insert Into( e, Eval Expr( Is Missing( Expr( nc ) ) ) )
);
dt << selectwhere( e );
表達式“e”看起來像
nameexpr(e)
/*:
Is Missing( :m1 ) | Is Missing( :m2 ) | Is Missing( :m3 ) | Is Missing( :m4 ) | Is Missing( :m5 ) | Is Missing( :m6 )
Head Arg 遞迴公式
內省

回覆:選擇包含空資料的儲存格您可以使用 STACK 指令來堆疊數據,包括 M1-Mn 的值。然後選擇空白行並將其刪除。
或試試這個程式碼:
dt = Current Data Table();
col_list = dt << get column names( Numeric, string );
where_clause = "";
For( i = 1, i <= N Items( nc ), i++,
one_col = col_list[i];
if (i == 1,
// then
where_clause =evalinsert("\[dt << select where(is missing(as column(dt, "^one_col^"))]\");
// else
,
where_clause = evalinsert("\[^where_clause^ | is missing(as column(dt, "^one_col^"))]\");
);
);
where_clause = where_clause || ")";
eval(parse(where_clause));