列
大家好,
我有幾個專欄:
1-“平均數”列
2-“數字”列
數字從 1 到 10,000。
通常屬於組 (2) 的每一列也應屬於組 (1),反之亦然。 所以我們應該在兩組中有相同數量的列。
但是,屬於第 1 組的列不屬於第 2 組,反之亦然。
例子: “平均 730”但“730”列不存在。
目標是讓這兩組相交,以便兩組中有相同的列。
數據表回复:colonnes關聯數組可以在製作交叉點時提供幫助集合運算中的關聯數組 (jmp.com)如果你能讓鑰匙看起來一樣。 或者您可以堆疊表,使它們看起來相似,然後執行連接。 我認為最困難的部分可能是如何獲得您感興趣的列列表,這取決於您的數據。
回复:專欄這些列在同一個數據表中。
這是從我的數據庫中獲取的示例:

我的目標是刪除“持續時間 721”、“730”和“750”列
回复:colonnes使用關聯數組的一種選擇
Names Default To Here(1);
dt = Open("$DOWNLOADS/AA.jmp");
// build
aa_duree = Associative Array();
aa_nonduree = Associative Array();
For Each({col_name}, dt << Get Column Names("String"),
If(Word(1, col_name) == "durée",
aa_duree[Word(-1, col_name)] = col_name;
, !IsMissing(Regex(col_name, "\d+")),
aa_nonduree[col_name] = 1;
,
continue()
);
);
aa_duree_copy = aa_duree;
aa_duree_copy << Intersect(aa_nonduree);
cols_to_keep = Insert(aa_duree_copy << get keys, aa_duree_copy << get values);
aa_duree_copy2 = aa_duree;
aa_nonduree_copy = aa_nonduree;
aa_duree_copy2 << remove(aa_nonduree);
aa_nonduree_copy << remove(aa_duree);
cols_to_remove = Insert(aa_nonduree_copy << get keys, aa_duree_copy2 << get values);
show(cols_to_keep, cols_to_remove);
還有其他選項,例如加入堆疊表或僅使用列表
回复:專欄太好了,謝謝,它有效!
但是列在“cols_to_remove”列表中,如何直接在數據表中刪除這些列?
回复:colonnes使用dt<<刪除列(column1, column2, ...)
