我正在尝试使用 matplotlib 绘制直方图。
我需要转换我的单行二维数组
[[1,2,3,4]] # shape is (1,4)
进入一维数组
[1,2,3,4] # shape is (4,)
我怎样才能做到这一点?
Adding ravel http://docs.scipy.org/doc/numpy/reference/generated/numpy.ravel.html作为未来搜索者的另一种选择。从文档中,
它相当于 reshape(-1, order=order)。
由于数组为 1xN,因此以下所有内容都是等效的:
arr1d = np.ravel(arr2d)
arr1d = arr2d.ravel()
arr1d = arr2d.flatten()
arr1d = np.reshape(arr2d, -1)
arr1d = arr2d.reshape(-1)
arr1d = arr2d[0, :]
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)