numpy.apply_over_axes
- 
numpy.apply_over_axes(func, a, axes)[source]
- 
Apply a function repeatedly over multiple axes. funcis called asres = func(a, axis), whereaxisis the first element ofaxes. The resultresof the function call must have either the same dimensions asaor one less dimension. Ifreshas one less dimension thana, a dimension is inserted beforeaxis. The call tofuncis then repeated for each axis inaxes, withresas the first argument.Parameters: func : function This function must take two arguments, func(a, axis).a : array_like Input array. axes : array_like Axes over which funcis applied; the elements must be integers.Returns: apply_over_axis : ndarray The output array. The number of dimensions is the same as a, but the shape can be different. This depends on whetherfuncchanges the shape of its output with respect to its input.See also - 
 apply_along_axis
- Apply a function to 1-D slices of an array along the given axis.
 NotesThis function is equivalent to tuple axis arguments to reorderable ufuncs with keepdims=True. Tuple axis arguments to ufuncs have been available since version 1.7.0. Examples>>> a = np.arange(24).reshape(2,3,4) >>> a array([[[ 0, 1, 2, 3], [ 4, 5, 6, 7], [ 8, 9, 10, 11]], [[12, 13, 14, 15], [16, 17, 18, 19], [20, 21, 22, 23]]])Sum over axes 0 and 2. The result has same number of dimensions as the original array: >>> np.apply_over_axes(np.sum, a, [0,2]) array([[[ 60], [ 92], [124]]])Tuple axis arguments to ufuncs are equivalent: >>> np.sum(a, axis=(0,2), keepdims=True) array([[[ 60], [ 92], [124]]])
- 
 
    © 2008–2017 NumPy Developers
Licensed under the NumPy License.
    https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.apply_over_axes.html