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)
| 3384 | |
| 3385 | @array_function_dispatch(_mean_dispatcher) |
| 3386 | def mean(a, axis=None, dtype=None, out=None, keepdims=np._NoValue, *, |
| 3387 | where=np._NoValue): |
| 3388 | """ |
| 3389 | Compute the arithmetic mean along the specified axis. |
| 3390 | |
| 3391 | Returns the average of the array elements. The average is taken over |
| 3392 | the flattened array by default, otherwise over the specified axis. |
| 3393 | `float64` intermediate and return values are used for integer inputs. |
| 3394 | |
| 3395 | Parameters |
| 3396 | ---------- |
| 3397 | a : array_like |
| 3398 | Array containing numbers whose mean is desired. If `a` is not an |
| 3399 | array, a conversion is attempted. |
| 3400 | axis : None or int or tuple of ints, optional |
| 3401 | Axis or axes along which the means are computed. The default is to |
| 3402 | compute the mean of the flattened array. |
| 3403 | |
| 3404 | .. versionadded:: 1.7.0 |
| 3405 | |
| 3406 | If this is a tuple of ints, a mean is performed over multiple axes, |
| 3407 | instead of a single axis or all the axes as before. |
| 3408 | dtype : data-type, optional |
| 3409 | Type to use in computing the mean. For integer inputs, the default |
| 3410 | is `float64`; for floating point inputs, it is the same as the |
| 3411 | input dtype. |
| 3412 | out : ndarray, optional |
| 3413 | Alternate output array in which to place the result. The default |
| 3414 | is ``None``; if provided, it must have the same shape as the |
| 3415 | expected output, but the type will be cast if necessary. |
| 3416 | See :ref:`ufuncs-output-type` for more details. |
| 3417 | |
| 3418 | keepdims : bool, optional |
| 3419 | If this is set to True, the axes which are reduced are left |
| 3420 | in the result as dimensions with size one. With this option, |
| 3421 | the result will broadcast correctly against the input array. |
| 3422 | |
| 3423 | If the default value is passed, then `keepdims` will not be |
| 3424 | passed through to the `mean` method of sub-classes of |
| 3425 | `ndarray`, however any non-default value will be. If the |
| 3426 | sub-class' method does not implement `keepdims` any |
| 3427 | exceptions will be raised. |
| 3428 | |
| 3429 | where : array_like of bool, optional |
| 3430 | Elements to include in the mean. See `~numpy.ufunc.reduce` for details. |
| 3431 | |
| 3432 | .. versionadded:: 1.20.0 |
| 3433 | |
| 3434 | Returns |
| 3435 | ------- |
| 3436 | m : ndarray, see dtype parameter above |
| 3437 | If `out=None`, returns a new array containing the mean values, |
| 3438 | otherwise a reference to the output array is returned. |
| 3439 | |
| 3440 | See Also |
| 3441 | -------- |
| 3442 | average : Weighted average |
| 3443 | std, var, nanmean, nanstd, nanvar |