Compute the arithmetic mean along the specified axis. Returns the average of the array elements. The average is taken over the flattened array by default, otherwise over the specified axis. `float64` intermediate and return values are used for integer inputs. Parameters -
(a, axis=None, dtype=None, out=None, keepdims=np._NoValue, *,
where=np._NoValue)
| 3736 | |
| 3737 | @array_function_dispatch(_mean_dispatcher) |
| 3738 | def mean(a, axis=None, dtype=None, out=None, keepdims=np._NoValue, *, |
| 3739 | where=np._NoValue): |
| 3740 | """ |
| 3741 | Compute the arithmetic mean along the specified axis. |
| 3742 | |
| 3743 | Returns the average of the array elements. The average is taken over |
| 3744 | the flattened array by default, otherwise over the specified axis. |
| 3745 | `float64` intermediate and return values are used for integer inputs. |
| 3746 | |
| 3747 | Parameters |
| 3748 | ---------- |
| 3749 | a : array_like |
| 3750 | Array containing numbers whose mean is desired. If `a` is not an |
| 3751 | array, a conversion is attempted. |
| 3752 | axis : None or int or tuple of ints, optional |
| 3753 | Axis or axes along which the means are computed. The default is to |
| 3754 | compute the mean of the flattened array. |
| 3755 | |
| 3756 | If this is a tuple of ints, a mean is performed over multiple axes, |
| 3757 | instead of a single axis or all the axes as before. |
| 3758 | dtype : data-type, optional |
| 3759 | Type to use in computing the mean. For integer inputs, the default |
| 3760 | is `float64`; for floating point inputs, it is the same as the |
| 3761 | input dtype. |
| 3762 | out : ndarray, optional |
| 3763 | Alternate output array in which to place the result. The default |
| 3764 | is ``None``; if provided, it must have the same shape as the |
| 3765 | expected output, but the type will be cast if necessary. |
| 3766 | See :ref:`ufuncs-output-type` for more details. |
| 3767 | See :ref:`ufuncs-output-type` for more details. |
| 3768 | |
| 3769 | keepdims : bool, optional |
| 3770 | If this is set to True, the axes which are reduced are left |
| 3771 | in the result as dimensions with size one. With this option, |
| 3772 | the result will broadcast correctly against the input array. |
| 3773 | |
| 3774 | If the default value is passed, then `keepdims` will not be |
| 3775 | passed through to the `mean` method of sub-classes of |
| 3776 | `ndarray`, however any non-default value will be. If the |
| 3777 | sub-class' method does not implement `keepdims` any |
| 3778 | exceptions will be raised. |
| 3779 | |
| 3780 | where : array_like of bool, optional |
| 3781 | Elements to include in the mean. See `~numpy.ufunc.reduce` for details. |
| 3782 | |
| 3783 | .. versionadded:: 1.20.0 |
| 3784 | |
| 3785 | Returns |
| 3786 | ------- |
| 3787 | m : ndarray, see dtype parameter above |
| 3788 | If `out=None`, returns a new array containing the mean values, |
| 3789 | otherwise a reference to the output array is returned. |
| 3790 | |
| 3791 | See Also |
| 3792 | -------- |
| 3793 | average : Weighted average |
| 3794 | std, var, nanmean, nanstd, nanvar |
| 3795 |
no outgoing calls
no test coverage detected
searching dependent graphs…