where

np.where(条件)は,条件がなりたつインデックスを返す.よくある使い方は,ある数値(範囲)を対象に操作をすることである.

たとえば,以下の例ではnumpy array x の0以下の要素を,0に置き換えている.

x[np.where<0.]=0.0

np.where(condition) returns index to which the condition is satisfied. This is often used for operating spcific value or value range.

For example, the following replace the elements smaller than zero of numpy array x by zero.

x[np.where<0.]=0.0