我在这里有这个数组:
a = np.array([[['1','2','3'],['10','11','12']],[['4','5','6'],['13','14','15']],[['7','8','9'],['16','17','18']]])
我想像这样转换它:
>>>[['1' '2' '3'] ['4' '5' '6'] ['7' '8' '9'] ['13' '14' '15'] ['10' '11' 12'] ['16' '17' '18']]
我正在使用Numpy的.flatten(),但无法正常工作
谢谢
答案 0 :(得分:3)
尝试:
a.transpose(1, 0, 2).reshape(-1, 3)