Numpy > array comparisons > np.all()の使用
@ Scipy lecture notes, Edition 2017.1
https://www.scipy-lectures.org/_downloads/ScipyLectures-simple.pdf
3.2.2 Basic reductions
Other reduction
p63
https://www.scipy-lectures.org/intro/numpy/operations.html#other-reductions
Note Can be used for array comparisons:
np.all()とnp.any()を使ったarray comparisonが可能とのこと。
import numpy as np
a = np.array([1, 2, 3, 2])
b = np.array([2, 2, 3, 2])
c = np.array([6, 4, 4, 5])
res = ((a <= b) & (b <= c)).all()
print(res)
run
True
比較した結果がリストでTrueかFalseの要素を持ち、それがすべてTrueの時にresがTrueになるという流れ。
.all()がない場合は、[True True True True]
がresに入る。
Author And Source
この問題について(Numpy > array comparisons > np.all()の使用), 我々は、より多くの情報をここで見つけました https://qiita.com/7of9/items/d9d4b5b34fb14e86705c著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .