用于动态循环并按名称对列进行分组的脚本所以我试图解决这个问题,但它不太有效。
我有一个带有键值对的表,我已将其从高分成宽。 我最终得到了大约 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 的部分,然后继续相应的操作。