我现在有个矩阵这样
array([[ 0.35441871, 27.2616325 ],
[ 3.66211698, 1.31750397],
[ 0.35441871, 27.2616325 ],
[ 3.66211698, 1.31750397],
[ 0.35441871, 27.2616325 ],
[ 3.66211698, 1.31750397],
[ 0.35441871, 27.2616325 ],
[ 3.66211698, 1.31750397]])
我想把它变形为这样
array([[[ 0.35441871, 27.2616325 ],
[ 0.35441871, 27.2616325 ],
[ 0.35441871, 27.2616325 ],
[ 0.35441871, 27.2616325 ]],
[[ 3.66211698, 1.31750397],
[ 3.66211698, 1.31750397],
[ 3.66211698, 1.31750397],
[ 3.66211698, 1.31750397]]])
请问我该如何在不使用循环的情况下直接得到,还要考虑更多数据矩阵如
array([[ 0.35441871, 27.2616325 ],
[ 3.66211698, 1.31750397],
[ 4.36211698, 9.21750397],
[ 0.35441871, 27.2616325 ],
[ 3.66211698, 1.31750397],
[ 4.36211698, 9.21750397],
[ 0.35441871, 27.2616325 ],
[ 3.66211698, 1.31750397],
[ 4.36211698, 9.21750397],
[ 0.35441871, 27.2616325 ],
[ 3.66211698, 1.31750397],
[ 4.36211698, 9.21750397],])
转为
array([[[ 0.35441871, 27.2616325 ],
[ 0.35441871, 27.2616325 ],
[ 0.35441871, 27.2616325 ],
[ 0.35441871, 27.2616325 ]],
[[ 3.66211698, 1.31750397],
[ 3.66211698, 1.31750397],
[ 3.66211698, 1.31750397],
[ 3.66211698, 1.31750397]],
[[ 4.36211698, 9.21750397],
[ 4.36211698, 9.21750397],
[ 4.36211698, 9.21750397],
[ 4.36211698, 9.21750397]]])
规律就是我有n组数据,需要
n,2n······nn都要和第0行合并
n+1,2n+1······nn+1都要和第1行合并
······
n+n-1,2n+n-1······nn+n-1和第n-1行合并
求教大神该如何解决