网站首页 文章专栏 使用np.where()
使用np.where()
创建于:2018-04-12 16:00:00 更新于:2024-04-20 15:03:49 羽瀚尘 592
python python,numpy

import: use & instead of and

Simply, use np.where(condition1 & condition2) will get the right answer, but `np.where( list(condition1) and list(condition2)) won't return the right answer.

So, please use &.

Further disscus

Try this python script:

a = [True, False, False]
b = [False, True, True]
print('a and b', a and b)

You will get:

a anb [False, True, True]

Reference: 1. numpy进阶:多条件查找 http://blog.sina.com.cn/s/blog_12c3192a50102xd5z.html