作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试将形状为 (80000,)
的 numpy 数组转换为 (80000,55)
我有如下数据[[1212,121,121],[12,122,111]]
转换此列表列表后,我得到了 (2,)
的形状,但我想要像 (2,3)
这样的形状如何去做。
最佳答案
In [68]: np.array([[1212,121,121],[12,122,111]] )
Out[68]:
array([[1212, 121, 121],
[ 12, 122, 111]])
In [69]: _.shape
Out[69]: (2, 3)
如果您得到类似 (2,) 的形状,可能是因为某些嵌套列表的形状不同。检查 dtype
以及 shape
。还要查看数组。
In [70]: np.array([[1212,121,121],[12,122,111,3]] )
Out[70]: array([list([1212, 121, 121]), list([12, 122, 111, 3])], dtype=object)
即将发布的版本将添加警告:
/usr/local/bin/ipython3:1: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray
#!/usr/bin/python3
关于python - 如何将形状数组 n, 转换为 n,m,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62364203/
我是一名优秀的程序员,十分优秀!