DolphinDB如何处理面板数据

我想用DolphinDB对一个面板数据做预处理:
这是我的原始数据表:

attachments-2021-05-s56tPsAl60ac70852a618.png我想把数据转换成如下:
其中列为日期,行是ID。

attachments-2021-05-0YqrO6m760ac7090cdbb7.png
...
如何实现面板数据的预处理?因为我的原始数据量很大,希望提供一个快速高效的方法。另外,date行并非连续日期,如果可以生成连续时间的面板数据,那就更好了。

请先 登录 后评论

1 个回答

Johhny

可以使用pivot by子句

ID=rand(`a`b`c, 100)
date=2015.08.07..2017.08.11
dates=rand(date, 100)
x=rand(10.0,100)

t=table(ID,dates,x)
select x from t pivot by dates, ID

如果需要连续日期的面板数据,可以使用 panel函数(DolphinDB 1.30.0.0及以上版本支持):

panel( t.dates,t.ID,t.x,date)

更多面板数据的案例请参阅https://gitee.com/dolphindb/T...

请先 登录 后评论