【发布时间】:2019-04-25 14:28:42
【问题描述】:
这是我将 40*1 数组重塑为 20*2 数组时遇到的问题的一个非常简单的版本。这里出了什么问题?
import numpy as np
x=np.linspace(1,20,40)
#confirm length is 40
print(np.shape(x))
#reshape to 2*20
print(np.reshape(x,2,20))
#returns error: 'total size of new array must be unchanged'
【问题讨论】:
-
如果我的回答有帮助,请告诉我
-
你没有仔细阅读文档
-
@seralouk 是的,它准确地回答了我的问题。谢谢!
标签: python numpy reshape numpy-ndarray