1
import numpy as np
a = np.array([[1,2],
[3,4],
[5,6],
[7,8],
[9,10],
[11,12]])
print np.shape(a)
預期的答案應該是:重新排列numpy的陣列
answer = np.array([[1,2,7,8],
[3,4, 9, 10],
[5,6, 11, 12]])
我嘗試作爲
ans = a.reshape(3,-1)
print ans
[[ 1 2 3 4]
[ 5 6 7 8]
[ 9 10 11 12]]
但答案是錯的。怎麼做?