動態循環遍歷並按名稱對列進行分組的腳本所以我試圖弄清楚這一點,它只是不太有效。
我有一個帶有鍵值對的表,我將其從高到寬拆分。 我最終得到了大約 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, :EquipmentId, :ChamberId, :LotId, :SlotNo ))
);
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();
);腳本回复:腳本以動態循環並按名稱對列進行分組有很多方法可以做到這一點。
這是一個示例,它首先將組構建為關聯數組,其中鍵作為組的名稱,值是組中的列列表,然後循環遍歷該關聯數組以對數據表中的列進行分組。 要獲取組名,我們對列名使用 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);
);

回复:腳本以動態循環並按名稱對列進行分組謝謝,很快就會試試這個。
但是動態構建分組數組列表呢? 基本上, :RecipeStepId 的每個唯一值都應該是 groupby 名稱。 我一開始就嘗試這樣做,在拆分錶格之前,將其保存到“RecipeStepIndex”
Summarize( dt, RecipeStepIndex = by( :RecipeStepId) );//get list of unique RecipeStepID's
回复:腳本以動態循環並按名稱對列進行分組例如,您可以使用基於 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);
);