用於動態循環並按名稱對列進行分組的腳本所以我試圖解決這個問題,但它不太有效。
我有一個帶有鍵值對的表,我已將其從高分成寬。 我最終得到了大約 10k 列,它們都有一個常規的命名結構,比如
“15.02.0 參數1”、“15.02 參數2”、“15.02 參數3”....“15.03 參數1”、“15.03 參數2”、“15.03 參數3”、...
如何查看所有這些列並按起始術語動態對它們進行分組? IE。一個組中的所有 15.02% 列、所有 15.03% 列、所有 15.04%、...所有 17.06%...並根據 groupby 編號命名該組?
我的腳本只是將所有內容分組到一個組中。呃。
//**split Aggregate Data from TALL to WIDE, grouping WIDE columns by StepID
dt = current data table();
Summarize( dt, RecipeStepIndex = by( :RecipeStepId) );//get list of unique RecipeStepID's
//split the table TALL to WIDE
dt << Split(
Split By( :RecipeStepId, :ParameterName, :AggregateFunction ),
Split( :Value ),
Group( :Recipe, :ProcessTime, :Tool, :Chamber, :Lot, :WaferScribe ),
Output Table( "AggWide" ),
Remaining Columns( Drop All ),
Sort by Column Property,
dt << sort( by( :Recipe, :Tool, :Chamber, :Lot, :WaferScribe ))<BR />
);
dtAggWide = current data table();
ColNamesList = dtAggWide << get column names(string, continuous); //get the column names of the WIDE table
//Create an empty list for the matching columns
RecipeStepList = {};
// Find matching column names
For( i = 1, i <= N items( RecipeStepIndex ), i++,
For( j = 1, j <= N Items( ColNamesList ), j++,
If(
Contains( ColNamesList[j], RecipeStepIndex[i] ),
Insert Into( RecipeStepList, ColNamesList[j] ),
);
);
);
// If groups of columns are found, create Col groupings
If( N Items( RecipeStepList ) > 0,
dtAggWide << select columns( RecipeStepList );
dtAggWide << group columns();
);數據混合和清理回复:動態循環並按名稱對列進行分組的腳本明白了。我想出瞭如何讓兩個版本都工作! 非常感謝和榮譽。
對於未來的任何人,這是我的完成版本:
V1=
//**split Aggregate Data from TALL to WIDE, grouping WIDE columns by StepID
dt = current data table();
//Build and prefill an Array of names of the RecipeStepId
Summarize( dt, RecipeStepIndex = by( :RecipeStepId) );//get list of unique RecipeStepID's
aa_groups = Associative Array(RecipeStepIndex, Repeat({{}}, N Items(RecipeStepIndex)));
//split the table TALL to WIDE
dt << Split(
Split By( :RecipeStepId, :ParameterName, :AggregateFunction ),
Split( :Value ),
Group( :Recipe, :ProcessTime, :Tool, :Chamber, :Lot, :WaferScribe ),
Output Table( "AggWide" ),
Remaining Columns( Drop All ),
Sort by Column Property,
dt << sort( by( :Recipe, :Tool, :Chamber, :Lot, :WaferScribe ))
);
//Group the Cols by name of RecipeStepId
col_list = dtAggWIDE << Get Column Names("String"); //get the col list
For Each({col_name}, col_list,
col_group = Word(1, col_name, " ");
If(!Contains(aa_groups, col_group),
aa_groups[col_group] = Eval List({col_name});
,
Insert Into(aa_groups[col_group], col_name);
);
);
For Each({{key, value}}, aa_groups, //perform the grouping
dtAggWide << Group Columns(key, value);
);
V2=
//**split Aggregate Data from TALL to WIDE, grouping WIDE columns by StepID
dt = current data table();
//Build and prefill an Array of names of the RecipeStepId
Summarize( dt, RecipeStepIndex = by( :RecipeStepId) );//get list of unique RecipeStepID's
aa_groups = Associative Array();
//split the table TALL to WIDE
dt << Split(
Split By( :RecipeStepId, :ParameterName, :AggregateFunction ),
Split( :Value ),
Group( :Recipe, :ProcessTime, :Tool, :Chamber, :Lot, :WaferScribe ),
Output Table( "AggWide" ),
Remaining Columns( Drop All ),
Sort by Column Property,
dt << sort( by( :Recipe, :Tool, :Chamber, :Lot, :WaferScribe ))
);
//Group the Cols by name of RecipeStepId
col_list = dtAggWide << Get Column Names("String");
For Each({col_name}, col_list,
col_group = Word(1, col_name, " ");
If(!Contains(aa_groups, col_group),
aa_groups[col_group] = {};
);
Insert Into(aa_groups[col_group], col_name)
);
For Each({{key, value}}, aa_groups, //perform the grouping
dtAggWide << Group Columns(key, value);
);回复:動態循環並按名稱對列進行分組的腳本我認為該錯誤意味著您在關聯數組中沒有鍵。 如果您嘗試了第二個代碼,您的代碼是否有這一行:
aa_groups = Associative Array(RecipeStepIndex, Repeat({{}}, N Items(RecipeStepIndex)));
它用於初始化aa_groups。 另外如果食譜步驟索引不匹配col_group = Word(1, col_name, “”);你會得到那個錯誤。 您可能需要為類似的情況添加一些額外的處理(添加將收集所有缺失列的組或僅添加找到的列)。
這應該跳過沒有匹配組的列。
For Each({col_name}, col_list,
col_group = Word(1, col_name, " ");
If(!Contains(aa_groups, col_group),
aa_groups[col_group] = Eval List({col_name});
,
Insert Into(aa_groups[col_group], col_name);
);
);
回复:動態循環並按名稱對列進行分組的腳本好吧,我想我明白你的意思了,我很困惑你為什麼要創建一個新的 dt,但看起來只是為了這個例子。
您的第二組代碼似乎對我不起作用,但第一組代碼卻對我有用。 知道這個錯誤意味著什麼嗎?

//Group the Cols by name of RecipeStepId
col_list = dtAggWIDE << Get Column Names("String");
For Each({col_name}, col_list,
col_group = Word(1, col_name, " ");
If(!Contains(aa_groups, col_group),
aa_groups[col_group] = {};
);
Insert Into(aa_groups[col_group], col_name)
);
Show(aa_groups);
For Each({{key, value}}, aa_groups,
dtAggWide << Group Columns(key, value);
);
回复:動態循環並按名稱對列進行分組的腳本dtAggWide 在那裡是因為它是包含要分組的列的數據表。 在上面的代碼中,您缺少對它的引用,添加它的最簡單和最好的方法是(這將避免使用 Current Data Table() ,它可能工作也可能不起作用):
dtAggWide = dt << Split(
Split By( :RecipeStepId, :RecipeStepName, :ParameterName, :AggregateFunction ),
Split( :Value ),
Group( :Recipe, :ProcessTime, :Tool, :Chamber, :Lot, :WaferScribe ),
Output Table( "AggWide" ),
Remaining Columns( Drop All ),
Sort by Column Property,
dt << sort( by( :Recipe, :Tool, :Chamber, :Lot, :WaferScribe ))
);
col_list 可以循環 dtAggWide 中的列,然後將列添加到 aa_groups 關聯數組中的正確列表中
回复:動態循環並按名稱對列進行分組的腳本唔。 我有點困惑,不確定你在這裡做什麼。
為什麼還有 dtAggWide 和 col_list?
//*****************************************************************
//**split Aggregate Data from TALL to WIDE, grouping WIDE columns by StepID
dt = current data table();
//Build and prefill an Array of names of the RecipeStepId
aa_groups = Associative Array();
Summarize( dt, RecipeStepIndex = by( :RecipeStepId) );//get list of unique RecipeStepID's
aa_groups = Associative Array(RecipeStepIndex, Repeat({{}}, N Items(RecipeStepIndex)));
//split the table TALL to WIDE
dt << Split(
Split By( :RecipeStepId, :RecipeStepName, :ParameterName, :AggregateFunction ),
Split( :Value ),
Group( :Recipe, :ProcessTime, :Tool, :Chamber, :Lot, :WaferScribe ),
Output Table( "AggWide" ),
Remaining Columns( Drop All ),
Sort by Column Property,
dt << sort( by( :Recipe, :Tool, :Chamber, :Lot, :WaferScribe ))
);
//Group the Cols by name of RecipeStepId
For Each({col_name}, col_list,
col_group = Word(1, col_name, " ");
Insert Into(aa_groups[col_group], col_name)
);
For Each({{key, value}}, aa_groups,
dtAggWide << Group Columns(key, value);
);回复:動態循環並按名稱對列進行分組的腳本例如,您可以使用基於 RecipeStepIndex 的列名稱“預填充”關聯數組。 最有可能的是,RecipeStepIndex 將從分割列名稱的開頭找到,因此這應該仍然有效。
Names Default To Here(1);
// this solution requires JMP16
dtAggWide = New Table("Untitled",
Add Rows(0),
New Column("15.02.0 param1", Numeric, "Continuous", Format("Best", 12), Set Values([])),
New Column("15.02.0 param2", Numeric, "Continuous", Format("Best", 12), Set Values([])),
New Column("15.02.0 param3", Numeric, "Continuous", Format("Best", 12), Set Values([])),
New Column("15.03 param1", Numeric, "Continuous", Format("Best", 12), Set Values([])),
New Column("15.03 param2", Numeric, "Continuous", Format("Best", 12), Set Values([]))
);
col_list = dtAggWide << Get Column Names("String");
// first get the column group names and columns// in this solution case we use associative array
aa_groups = Associative Array();
//Summarize(dt, RecipeStepIndex = by(:RecipeStepId));//get list of unique RecipeStepID's
RecipeStepIndex = {"15.02.0", "15.03"};
aa_groups = Associative Array(RecipeStepIndex, Repeat({{}}, N Items(RecipeStepIndex)));
For Each({col_name}, col_list,
col_group = Word(1, col_name, " ");
Insert Into(aa_groups[col_group], col_name)
);
For Each({{key, value}}, aa_groups,
dtAggWide << Group Columns(key, value);
);
回复:動態循環並按名稱對列進行分組的腳本謝謝,很快就會嘗試這個。
但是動態構建分組數組列表又如何呢? 基本上,:RecipeStepId 的每個唯一值都應該是一個 groupby 名稱。 我一開始就嘗試這樣做,然後拆分錶格,將其保存到“RecipeStepIndex”
Summarize( dt, RecipeStepIndex = by( :RecipeStepId) );//get list of unique RecipeStepID's
回复:動態循環並按名稱對列進行分組的腳本有很多方法可以做到這一點。
下面是一個示例,它首先將組構建為關聯數組,鍵作為組的名稱,值是組中的列列表,然後循環該關聯數組以對數據表中的列進行分組。 為了獲取組名稱,我們對列名稱使用 Word() 函數。 由於使用 For Each,這需要 JMP16
Names Default To Here(1);
// this solution requires JMP16
dtAggWide = New Table("Untitled",
Add Rows(0),
New Column("15.02.0 param1", Numeric, "Continuous", Format("Best", 12), Set Values([])),
New Column("15.02.0 param2", Numeric, "Continuous", Format("Best", 12), Set Values([])),
New Column("15.02.0 param3", Numeric, "Continuous", Format("Best", 12), Set Values([])),
New Column("15.03 param1", Numeric, "Continuous", Format("Best", 12), Set Values([])),
New Column("15.03 param2", Numeric, "Continuous", Format("Best", 12), Set Values([]))
);
col_list = dtAggWide << Get Column Names("String");
// first get the column group names and columns<BR />// in this solution case we use associative array
aa_groups = Associative Array();
For Each({col_name}, col_list,
col_group = Word(1, col_name, " ");
If(!Contains(aa_groups, col_group),
aa_groups[col_group] = {};
);
Insert Into(aa_groups[col_group], col_name)
);
Show(aa_groups);
For Each({{key, value}}, aa_groups,
dtAggWide << Group Columns(key, value);
);

回覆:動態循環並按名稱對列進行分組的腳本有什麼方法可以搜尋特定字符,然後將其用作群組名稱嗎?這樣它的第一部分的動態長度?
回覆:動態循環並按名稱對列進行分組的腳本您將修改確定 col_group 的部分,然後相應地繼續。