DolphinDB:如何在保留数组向量元素顺序的同时删除重复数据?

问题描述 投票:0回答:1

我想对下图中的“b”列进行重复数据删除,但是

distinct
函数不能与
group by
context by
子句一起使用,也不能保留元素的顺序。除了使用
isDuplicated
功能对表进行解组和去重之外,还有其他方法吗?

sorting distinct dolphindb
1个回答
1
投票

可以使用循环函数,如下脚本所示:

t = table(`a`b as sym, array(INT[]).append!([1 2 1, 2 3 2]) as val)
// Not preserving the order
select sym, loop(distinct,val) as`val from t 

// Preserving the order
select sym, loop(x -> x[ifirstHit{==,x,}:E(distinct x).sort()], val) as `val from t 
© www.soinside.com 2019 - 2024. All rights reserved.