在DolphinDB中如何取消分组一个数组向量?

huangapple go评论73阅读模式
英文:

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;

在DolphinDB中如何取消分组一个数组向量?

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.

huangapple
  • 本文由 发表于 2023年7月3日 10:55:08
  • 转载请务必保留本文链接:https://go.coder-hub.com/76601609.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定