如何查找范围之间的数字?
c = array[2,3,4,5,6]
>>> c>3
>>> array([False, False, True, True, True]
但是,当我在两个数字之间给出c时,它会返回错误
>>> 2<c<5
>>> ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
欲望输出是
array([False, True, True, False, False]
答案 0 :(得分:8)
试试这个,
(c > 2) & (c < 5)
<强>结果强>
array([False, True, True, False, False], dtype=bool)
答案 1 :(得分:2)
Python将(2<c) and (c<5)
评估为有效and
,除了and
关键字不能像numpy数组那样工作。 (它尝试将每个数组转换为单个布尔值,并且不能覆盖该行为,如所讨论的here。)因此,对于具有numpy数组的向量化(2<c) & (c<5)
操作,您需要这样做:< / p>
Just Get Row and its first parameter is your id and pass it into your deleteclick function
{
'data': null,
'render': function (data, type, row)
{
var id = row.id;
return '<button id="' + row.id + '" class="dodo" onclick="deleteClick("' + id + '")">Delete</button>'
}
}
function deleteClick(var id)
{
alert(id);
}
答案 2 :(得分:1)
您可以这样做:
import numpy as np
c = np.array([2,3,4,5,6])
output = [(i and j) for i, j in zip(c>2, c<5)]
输出:
[False, True, True, False, False]