where expressionnp where(cond cond np where(cond np where(cond ))in this particular examplewe can also take advantage of the fact that boolean values are treated as or in calculationsso this could alternatively be expressed (though bit more crypticallyas an arithmetic operationresult cond cond -(cond cond mathematical and statistical methods set of mathematical functions which compute statistics about an entire array or about the data along an axis are accessible as array methods aggregations (often called reductionslike summeanand standard deviation std can either be used by calling the array instance method or using the top level numpy functionin [ ]arr np random randn( normally-distributed data in [ ]arr mean(out[ ] in [ ]np mean(arrout[ ] in [ ]arr sum(out[ ] functions like mean and sum take an optional axis argument which computes the statistic over the given axisresulting in an array with one fewer dimensionin [ ]arr mean(axis= out[ ]array([- - ]in [ ]arr sum( out[ ]array([- - ]other methods like cumsum and cumprod do not aggregateinstead producing an array of the intermediate resultsin [ ]arr np array([[ ][ ][ ]]in [ ]arr cumsum( out[ ]array([ ] ] ]]in [ ]arr cumprod( out[ ]array([ ] ] ]]see table - for full listing we'll see many examples of these methods in action in later numpy basicsarrays and vectorized computation www it-ebooks info