Compute the arithmetic mean along the specified axis, ignoring NaNs. 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. F
(a, axis=None, dtype=None, out=None, keepdims=np._NoValue,
*, where=np._NoValue)
| 951 | |
| 952 | @array_function_dispatch(_nanmean_dispatcher) |
| 953 | def nanmean(a, axis=None, dtype=None, out=None, keepdims=np._NoValue, |
| 954 | *, where=np._NoValue): |
| 955 | """ |
| 956 | Compute the arithmetic mean along the specified axis, ignoring NaNs. |
| 957 | |
| 958 | Returns the average of the array elements. The average is taken over |
| 959 | the flattened array by default, otherwise over the specified axis. |
| 960 | `float64` intermediate and return values are used for integer inputs. |
| 961 | |
| 962 | For all-NaN slices, NaN is returned and a `RuntimeWarning` is raised. |
| 963 | |
| 964 | Parameters |
| 965 | ---------- |
| 966 | a : array_like |
| 967 | Array containing numbers whose mean is desired. If `a` is not an |
| 968 | array, a conversion is attempted. |
| 969 | axis : {int, tuple of int, None}, optional |
| 970 | Axis or axes along which the means are computed. The default is to compute |
| 971 | the mean of the flattened array. |
| 972 | dtype : data-type, optional |
| 973 | Type to use in computing the mean. For integer inputs, the default |
| 974 | is `float64`; for inexact inputs, it is the same as the input |
| 975 | dtype. |
| 976 | out : ndarray, optional |
| 977 | Alternate output array in which to place the result. The default |
| 978 | is ``None``; if provided, it must have the same shape as the |
| 979 | expected output, but the type will be cast if necessary. |
| 980 | See :ref:`ufuncs-output-type` for more details. |
| 981 | keepdims : bool, optional |
| 982 | If this is set to True, the axes which are reduced are left |
| 983 | in the result as dimensions with size one. With this option, |
| 984 | the result will broadcast correctly against the original `a`. |
| 985 | |
| 986 | If the value is anything but the default, then |
| 987 | `keepdims` will be passed through to the `mean` or `sum` methods |
| 988 | of sub-classes of `ndarray`. If the sub-classes methods |
| 989 | does not implement `keepdims` any exceptions will be raised. |
| 990 | where : array_like of bool, optional |
| 991 | Elements to include in the mean. See `~numpy.ufunc.reduce` for details. |
| 992 | |
| 993 | .. versionadded:: 1.22.0 |
| 994 | |
| 995 | Returns |
| 996 | ------- |
| 997 | m : ndarray, see dtype parameter above |
| 998 | If `out=None`, returns a new array containing the mean values, |
| 999 | otherwise a reference to the output array is returned. Nan is |
| 1000 | returned for slices that contain only NaNs. |
| 1001 | |
| 1002 | See Also |
| 1003 | -------- |
| 1004 | average : Weighted average |
| 1005 | mean : Arithmetic mean taken while not ignoring NaNs |
| 1006 | var, nanvar |
| 1007 | |
| 1008 | Notes |
| 1009 | ----- |
| 1010 | The arithmetic mean is the sum of the non-NaN elements along the axis |
nothing calls this directly
no test coverage detected
searching dependent graphs…