如何从表中获得标签列,该表由pivot函数获得的矩阵转换?

  • 本文关键字:函数 pivot 转换 标签 dolphindb
  • 更新时间 :
  • 英文 :


我通过函数枢轴得到矩阵,然后我通过函数表把它转换成一个表。我发现表丢失了标签列。如何保存标签列在这个表?

示例代码如下:

syms=`600300`600400`600500$SYMBOL
sym=syms[0 0 0 0 0 0 0 1 1 1 1 1 1 1 2 2 2 2 2 2 2]
time=09:40:00+1 30 65 90 130 185 195 10 40 90 140 160 190 200 5 45 80 140 170 190 210
price=172.12 170.32 172.25 172. 175.1 174.85 174.5 36.45 36.15 36.3 35.9 36.5 37.15 36.9 40.1 40.2 40.25 40.15 40.1 40.05 39.95
volume=100 * 10 3 7 8 25 6 10 4 5 1 2 8 6 10 2 2 5 5 4 4 3
t1=table(sym, time, price, volume);
stockprice=pivot(wavg, [t1.price, t1.volume], minute(t1.time), t1.sym)
stockprice.round(2);

我得到的数据是stockprice

<表类>标签600300600400600500tbody><<tr>09:40m171.736.2840.1509:41m172.4136.340.2509:42m175.136.3840.1309:43m174.6336.9940.01

使用rowNames()获取表的标签

t2=table(stockprice)
t2[`label]=stockprice.rowNames() 

使用reorderColumns()将标签放在最后一列

t2.reorderColumns!(`label join t2.colNames()[:t2.colNames().size()-1])

最新更新