Mat*_*att 5 numpy python-2.7 deprecation-warning
这段代码
import numpy as np
def some_method(y, threshold):
print type(y), y.shape, y.dtype
c = np.zeros(y.shape)
c[y > threshold] = 1
Run Code Online (Sandbox Code Playgroud)
结果是
<type 'numpy.ndarray'> (484L,) [('target', '<f8')]
DeprecationWarning: using a boolean instead of an integer will result in an error in the future
c[y > threshold] = 1
Run Code Online (Sandbox Code Playgroud)
我在谷歌和numpy发行说明中找不到任何相关内容.我假设这是关于布尔值的索引?我不明白这将如何导致将来出现错误,我该如何解决这个问题?
win32上的Python 2.7.6(默认,2013年11月10日,19:24:24)[MSC v.1500 64位(AMD64)]
Numpy版本:1.8.0
编辑:在代码中添加了print语句,以显示数组是一个ndarray
编辑2:从评论中可以清楚地看到,这y是因为是一个结构数组,并且检查的正确方法是y['target'] > threshold.但是,y有多个列,甚至是不同的列名,有没有办法灵活地使用结构化数组?