gpt4 book ai didi

kdb - 在每个内部使用翻转在 KDB 中不起作用

转载 作者:行者123 更新时间:2023-12-03 18:22:07 25 4
gpt4 key购买 nike

在表上使用 each,我希望 each 以单行表的形式一次对一行进行操作。但是,它首先被转换为字典:

q) t:flip `a`b!(enlist 1;enlist 2);
q) {type x} each t
enlist 99h / dictionary

所以显而易见的事情就是使用 flip 将字典变成表格:

q) {type flip x} each t
An error occurred during execution of the query.
The server sent the response:
rank
Studio Hint: Possibly this error refers to invalid rank or valence

嗯 - 这很奇怪。不能翻转字典??出了什么问题?

最佳答案

请记住,表是一个字典列表。

q)show each ([]a:1 2 3;b:4 5 6);
a| 1
b| 4
a| 2
b| 5
a| 3
b| 6

http://code.kx.com/q4m3/8_Tables/

每个字典的值都是原子,而不是列表。所以你不能以这种方式翻转字典到表格中,你必须确保值是列表。

q)enlist each ([]a:1 2 3;b:4 5 6)
+`a`b!(,1;,4)
+`a`b!(,2;,5)
+`a`b!(,3;,6)
q)type each enlist each ([]a:1 2 3;b:4 5 6)
98 98 98h

关于kdb - 在每个内部使用翻转在 KDB 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23286656/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com