英文:
How to ungroup an array vector in DolphinDB?
问题
使用toArray
函数与group by
子句,我按"ticker"列对"volume"列进行了分组,并将分组的值连接成一个数组向量。
ticker = `AAPL`IBM`IBM`AAPL`AMZN`AAPL`AMZN`IBM`AMZN
volume = 106 115 121 90 130 150 145 123 155;
t = table(ticker, volume);
t;
t1 = select toArray(volume) as volume_all from t group by ticker;
t1;
现在我想取消数组向量,即“volume_all”列。有人知道如何做吗?
英文:
Using the toArray
function with the group by
clause, I grouped the "volume" column by the "ticker" column, and concatenated the grouped values into an array vector.
ticker = `AAPL`IBM`IBM`AAPL`AMZN`AAPL`AMZN`IBM`AMZN
volume = 106 115 121 90 130 150 145 123 155;
t = table(ticker, volume);
t;
t1 = select toArray(volume) as volume_all from t group by ticker;
t1;
Now I want to ungroup the array vector, i,e., the “volume_all“ column. Does anyone know how to do this?
答案1
得分: 1
以下是翻译好的部分:
你可以参考以下的脚本:
ticker = `AAPL`IBM`IBM`AAPL`AMZN`AAPL`AMZN`IBM`AMZN
volume = 106 115 121 90 130 150 145 123 155;
t = table(ticker, volume);
t1 = select toArray(volume) as volume_all from t group by ticker;
unionAll(peach(x->table(take(x.ticker,size(x.volume_all)) as ticker, x.volume_all as volume),t1),0)
在2.00.10版本中将发布内置函数`ungroup`以实现此目的。
英文:
You can refer to the following script:
ticker = `AAPL`IBM`IBM`AAPL`AMZN`AAPL`AMZN`IBM`AMZN
volume = 106 115 121 90 130 150 145 123 155;
t = table(ticker, volume);
t1 = select toArray(volume) as volume_all from t group by ticker;
unionAll(peach(x->table(take(x.ticker,size(x.volume_all)) as ticker, x.volume_all as volume),t1),0)
A built-in function ungroup
will be released in the 2.00.10 version for this purpose.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论