without sacrificing performance there isin factbut it requires some indexing gymnasticsdef demean_axis(arraxis= )means arr mean(axisthis generalized things like [::np newaxisto dimensions indexer [slice(none)arr ndim indexer[axisnp newaxis return arr means[indexersetting array values by broadcasting the same broadcasting rule governing arithmetic operations also applies to setting values via array indexing in the simplest casewe can do things likein [ ]arr np zeros(( )in [ ]arr[: in [ ]arr out[ ]array([ ] ] ] ]]howeverif we had one-dimensional array of values we wanted to set into the columns of the arraywe can do that as long as the shape is compatiblein [ ]col np array([ - ]in [ ]arr[:col[:np newaxisin [ ]arr out[ ]array([ ][- - - ] ] ]]in [ ]arr[: [[- ][ ]in [ ]arr out[ ]array([[- - - ] ] ] ]]advanced ufunc usage while many numpy users will only make use of the fast element-wise operations provided by the universal functionsthere are number of additional features that occasionally can help you write more concise code without loops advanced ufunc usage www it-ebooks info