如何删除kdb中具有重复值的行?
我在kdb中有一个数据表,我想使用q删除在一列中包含重复值的行 例如,如果下表中的如何删除kdb中具有重复值的行?,kdb,Kdb,我在kdb中有一个数据表,我想使用q删除在一列中包含重复值的行 例如,如果下表中的Age列中存在重复值: Name Age Degree --------------------- Alice 26 Science Bob 34 Arts Carrie 26 Engineering 我将如何删除第三行,以获得以下结果: Name Age Degree --------------------- Alice 26 Scie
Age
列中存在重复值:
Name Age Degree
---------------------
Alice 26 Science
Bob 34 Arts
Carrie 26 Engineering
我将如何删除第三行,以获得以下结果:
Name Age Degree
---------------------
Alice 26 Science
Bob 34 Arts
谢谢 你可以这样做
select from t where i=(first;i)fby Age
你可以
select from t where i=(first;i)fby Age
您可以使用以下方法删除任何列中的任何重复项:
q)delete from t where ({not x in 1#x};i) fby Age
Name Age Degree
-----------------
Alice 26 Science
Bob 34 Arts
也可以使用by子句而不是fby来解决,但在这种情况下,要获得每个年龄的第一次出现,必须使用反向
q)0!select by Age from reverse t
Age Name Degree
-----------------
26 Alice Science
34 Bob Arts
您可以使用以下方法删除任何列中的任何重复项:
q)delete from t where ({not x in 1#x};i) fby Age
Name Age Degree
-----------------
Alice 26 Science
Bob 34 Arts
也可以使用by子句而不是fby来解决,但在这种情况下,要获得每个年龄的第一次出现,必须使用反向
q)0!select by Age from reverse t
Age Name Degree
-----------------
26 Alice Science
34 Bob Arts