the work is being done in pure pythonsecondlyit will not work with multidimensional arrays with np where you can write this very conciselyin [ ]result np where(condxarryarrin [ ]result out[ ]array( ]the second and third arguments to np where don' need to be arraysone or both of them can be scalars typical use of where in data analysis is to produce new array of values based on another array suppose you had matrix of randomly generated data and you wanted to replace all positive values with and all negative values with - this is very easy to do with np wherein [ ]arr randn( in [ ]arr out[ ]array([ [- - [- ] ] - ] - ]]in [ ]np where(arr - out[ ]array([ ][- - ][- - ] - ]]in [ ]np where(arr arrset only positive values to out[ ]array([ ][- - ][- - ] - ]]the arrays passed to where can be more than just equal sizes array or scalers with some cleverness you can use where to express more complicated logicconsider this example where have two boolean arrayscond and cond and wish to assign different value for each of the possible pairs of boolean valuesresult [for in range( )if cond [iand cond [ ]result append( elif cond [ ]result append( elif cond [ ]result append( elseresult append( data processing using arrays www it-ebooks info