each of numpy' binary ufuncs has special methods for performing certain kinds of special vectorized operations these are summarized in table - but 'll give few concrete examples to illustrate how they work reduce takes single array and aggregates its valuesoptionally along an axisby performing sequence of binary operations for examplean alternate way to sum elements in an array is to use np add reducein [ ]arr np arange( in [ ]np add reduce(arrout[ ] in [ ]arr sum(out[ ] the starting value ( for adddepends on the ufunc if an axis is passedthe reduction is performed along that axis this allows you to answer certain kinds of questions in concise way as less trivial examplewe can use np logical_and to check whether the values in each row of an array are sortedin [ ]arr randn( in [ ]arr[:: sort( sort few rows in [ ]arr[::- arr[: :out[ ]array([truetruetruetrue][falsetruefalsefalse]truetruetruetrue]truefalsetruetrue]truetruetruetrue]]dtype=boolin [ ]np logical_and reduce(arr[::- arr[: :]axis= out[ ]array(truefalsetruefalsetrue]dtype=boolof courselogical_and reduce is equivalent to the all method accumulate is related to reduce like cumsum is related to sum it produces an array of the same size with the intermediate "accumulatedvaluesin [ ]arr np arange( reshape(( )in [ ]np add accumulate(arraxis= out[ ]array([ ] ][ ]]outer performs pairwise cross-product between two arraysin [ ]arr np arange( repeat([ ] advanced numpy www it-ebooks info