我有一个 numpy ndarray 的 3D 坐标,格式如下。
array([[ 0., 0., 60.],
[ 0., 40., 60.],
[ 0., 40., 0.],
...,
[ 6., 0., 2.],
[ 4., 0., 2.],
[ 2., 0., 2.]])
我正在尝试 reshape 它,以便获得 2D 坐标网格,而不是 1D 坐标向量。
原始数组的长度为 1302,这应该允许我将其 reshape 为 21x62 的排列。
我尝试了 coords_reshape = np.ndarray.reshape(coords, (21,62))
但这抛出了错误,
ValueError: total size of new array must be unchanged
那么我在这里缺少什么?
最佳答案
coords_reshaped = coords.reshape((21, 62, 3))
关于python - reshape numpy ndarray,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38248677/