Numpyで動作は確認しているがlistで動作するかは未確認 -> 2019.5.13 listの場合を追加 これは覚えておくと便利 numpyの場合 listの場合 numpyの場合 条件に合うものを抽出 a = numpy.array([1,2,3,4,5,6]) a = a[a%2 ==0] >>array([2, 4, 6]) #←条件が合う要素のみが返る 2016.11.13追記:np.whereでも同じ様に動作。np.whereは条件が一致するインデックスを返すみたい。 a = a[np.where(a%2 == 0)] # 複数条件の場合は a = a[np.where((a%2 == 0) & (a > 2))] Trueになっているインデックスと同じ要素を抽出 a = numpy.array([1,2,3,4,5,6]) b = numpy.array([-3,-2,-1