我通过函数枢轴得到矩阵,然后我通过函数表把它转换成一个表。我发现表丢失了标签列。如何保存标签列在这个表?
示例代码如下:
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
<表类>标签 600300 600400 600500 tbody><<tr>09:40m 171.7 36.28 40.15 09:41m 172.41 36.3 40.25 09:42m 175.1 36.38 40.13 09:43m 174.63 36.99 40.01 表类>
使用rowNames()获取表的标签
t2=table(stockprice)
t2[`label]=stockprice.rowNames()
使用reorderColumns()将标签放在最后一列
t2.reorderColumns!(`label join t2.colNames()[:t2.colNames().size()-1])