dolphindb 怎么把内存表转置,类似pandas.T

attachments-2022-07-tESAyzAn62d12ae74797d.png

请先 登录 后评论

1 个回答

mhxiang

可以用矩阵的转置transpose

 tb=table(`str+string(1..10) as name,rand(1.,10) as col1,rand(1.,10) as col2,rand(1.,10) as col3)
m=transpose(matrix(exec col1,col2,col3 from tb)).rename!(tb.name)

也可以通过unpivot和pivot by实现

tb=table(`str+string(1..10) as name,rand(1.,10) as col1,rand(1.,10) as col2,rand(1.,10) as col3)
//tb=tb.unpivot(`name, `col1`col2`col3)
select value from tb.unpivot(`name, `col1`col2`col3)  pivot by valueType as value,name

attachments-2022-07-qPcHGVJ062d12baa3975e.png

请先 登录 后评论
  • 1 关注
  • 0 收藏,874 浏览
  • haaha 提出于 2022-07-15 16:52

相似问题