首页 > 解决方案 > 如何在浮点数组中找到“dtype('O')”?

问题描述

在尝试从 a 构造 acsr_matrixarray,我收到此错误:

In [83]: np.info(urt[0,0])
float(x) -> floating point number

Convert a string or number to a floating point number, if possible.

In [84]: np.info(urt)
class:  ndarray
shape:  (18586, 18586)
strides:  (148688, 8)
itemsize:  8
aligned:  True
contiguous:  True
fortran:  False
data pointer: 0xa85bf0040
byteorder:  little
byteswap:  False
type: object

In [84]: csr_matrix(urt)
...
TypeError: no supported conversion for types: (dtype('O'),)

这大概是因为,在某处,array出现了某种for的数组协议 ( dtype) *。'O'Object

所以我需要在构建csr_matrix. 因此我的问题是,我怎样才能Objectarray其他包含float的 s 中找到 ?

*我不知道如何Object偷偷进入,array但我怀疑它可能是一个任意精度数。

标签: pythonnumpy-ndarray

解决方案


推荐阅读