删除符合数字条件的列你好
我的表中有几千列,并希望将其修剪为大多数具有非零数字的列。即删除或分组并折叠那些具有超过一半行的零的列。有小费吗?
谢谢!
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。所以它奏效了。