Difference between Numpy’s All and Any MethodsIf you want to get the row whose ALL values satisfy a certain condition, use numpy’s all method. To get the row whose AT LEAST one value satisfies a certain condition, use numpy’s any method.
Если вы хотите получить строку, ВСЕ значения которой удовлетворяют определенному условию, используйте метод numpy's all. Чтобы получить строку, в которой хотя бы одно значение удовлетворяет определенному условию, используйте метод numpy's any.
В приведенном коде показана разница в выводах между all и any.import numpy as np
a = np.array([[1, 2, 1], [2, 2, 5]])
# get the rows whose all values are fewer than 3
mask_all = (a<3).all(axis=1)
print(a[mask_all])
"""
[[1 2 1]]
"""
mask_any = (a<3).any(axis=1)
print(a[mask_any])
"""
[[1 2 1]
[2 2 5]]
"""
Numpy docs
@pythonl