刪除符合數字條件的列你好
我的表中有幾千列,並希望將其修剪為大多數具有非零數字的列。即刪除或分組並折疊那些具有超過一半行的零的列。有小費嗎?
謝謝!
Re:刪除符合數字條件的列我沒有測試它,但這個腳本給你一個想法。
Names Default to Here( 1 );
// assume that data table is open and reference to it is stored in variable dt
For( c = N Col( dt ), c > 0, c--,
n zero = dt << Get Rows Where( Column( c )[] == 0 );
If( n zero / N Row( dt ) > 0.5,
dt << Delete Columns( Column( c ) );
);
);
Re:刪除符合數字條件的列謝謝 - 表是開放的,但是需要一些關於如何在dt變量中引用它的synatx的幫助。
<SPAN class="token comment">// assume that data table is open and reference to it is stored in variable dt</SPAN>
Re:刪除符合數字條件的列dt = Current Data Table();
Re:刪除符合數字條件的列它正在渲染JMP無響應!不是由CPU活動 - 但只是不能與表窗口交互幾分鐘...
Re:刪除符合數字條件的列對於大數據表,矩陣解決方案可能比迭代所有列更快。
例:
dt = Current Data Table();
m = dt << get all columns as matrix; // Get table as matrix
// Get list of columns with > 50% zeroes
zero_cols = (dt << get column names)[(Loc(V Sum(m == 0) / N Row(m) > 0.5))];
// Delete them (or group them)
dt << Delete Columns(zero_cols);
// dt << Group Columns("zero", zero_cols);
Re:刪除符合數字條件的列我的桌子有55K cols,這個刪除了~17K。所以它奏效了。