放入带有条件的表的列表值我有这张桌子:
义务 |价值观
0 | 1638
1 | 618
2 | 486
3 | 9418
0 | 654
1 | 791
2 | 1398
3 | 4836
...
我想放入一个列表,所有的值都是 0,所以有这个:list = { 1638, 654 }
使用什么语法?
数据表回复:放入带有条件的表的列表值我的首选方法是使用数据表下标使用 Loc,但还有许多其他方法可以实现这一点
Names Default To Here(1);
dt = New Table("Untitled",
Add Rows(8),
New Column("dut", Numeric, "Continuous", Format("Best", 12), Set Values([0, 1, 2, 3, 0, 1, 2, 3])),
New Column("value", Numeric, "Continuous", Format("Best", 12), Set Values([1638, 618, 486, 9418, 654, 791, 1398, 4836]))
);
zero_rows = Loc(dt[0, "dut"], 0);
list_of_values = dt[zero_rows, "value"]; // and you can convert this to list with As List();
回复:放入带有条件的表的列表值这是相同解决方案的另一种方法
Names Default To Here(1);
dt = New Table("Untitled",
Add Rows(8),
New Column("dut", Numeric, "Continuous", Format("Best", 12), Set Values([0, 1, 2, 3, 0, 1, 2, 3])),
New Column("value", Numeric, "Continuous", Format("Best", 12), Set Values([1638, 618, 486, 9418, 654, 791, 1398, 4836]))
);
theList = As List( :value[dt << get rows where( :dut == 0 )] );
Show( theList );
theList = as list(:value[dt<<get rows where(:dut == 0)])
/*:
{1638, 654}