nanmean#
- ivy.nanmean(a, /, *, axis=None, keepdims=False, dtype=None, out=None)[source]#
Compute the mean of all non-NaN elements along the specified dimensions.
- Parameters:
a (
Array
) – Input array.axis (
Optional
[Union
[int
,Tuple
[int
]]], default:None
) – Axis or axes along which the means are computed. The default is to compute the mean of the flattened array.keepdims (
bool
, default:False
) – If this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the original a. If the value is anything but the default, then keepdims will be passed through to the mean or sum methods of sub-classes of ndarray. If the sub-classes methods does not implement keepdims any exceptions will be raised.dtype (
Optional
[Union
[Dtype
,NativeDtype
]], default:None
) – The desired data type of returned tensor. Default is None.out (
Optional
[Array
], default:None
) – optional output array, for writing the result to.
- Return type:
- Returns:
ret – The nanmean of the array elements.
Examples
>>> a = ivy.array([[1, ivy.nan], [3, 4]]) >>> ivy.nanmean(a) 2.6666666666666665 >>> ivy.nanmean(a, axis=0) ivy.array([2., 4.])
- Array.nanmean(self, /, *, axis=None, keepdims=False, dtype=None, out=None)[source]#
ivy.Array instance method variant of ivy.nanmean. This method simply wraps the function, and so the docstring for ivy.nanmean also applies to this method with minimal changes.
- Parameters:
self (
Array
) – Input array.axis (
Optional
[Union
[int
,Tuple
[int
]]], default:None
) – Axis or axes along which the means are computed. The default is to compute the mean of the flattened array.keepdims (
bool
, default:False
) – If this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the original a. If the value is anything but the default, then keepdims will be passed through to the mean or sum methods of sub-classes of ndarray. If the sub-classes methods does not implement keepdims any exceptions will be raised.dtype (
Optional
[Union
[Dtype
,NativeDtype
]], default:None
) – The desired data type of returned tensor. Default is None.out (
Optional
[Array
], default:None
) – optional output array, for writing the result to.
- Return type:
Array
- Returns:
ret – The nanmean of the array elements.
Examples
>>> a = ivy.array([[1, ivy.nan], [3, 4]]) >>> a.nanmean() 2.6666666666666665 >>> a.nanmean(axis=0) ivy.array([2., 4.])
- Container.nanmean(self, /, *, axis=None, keepdims=False, dtype=None, out=None)[source]#
ivy.Container instance method variant of ivy.nanmean. This method simply wraps the function, and so the docstring for ivy.nanmean also applies to this method with minimal changes.
- Parameters:
self (
Container
) – Input container including arrays.axis (
Optional
[Union
[int
,Tuple
[int
],Container
]], default:None
) – Axis or axes along which the means are computed. The default is to compute the mean of the flattened array.keepdims (
Union
[bool
,Container
], default:False
) – If this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the original a. If the value is anything but the default, then keepdims will be passed through to the mean or sum methods of sub-classes of ndarray. If the sub-classes methods does not implement keepdims any exceptions will be raised.dtype (
Optional
[Union
[Dtype
,NativeDtype
,Container
]], default:None
) – The desired data type of returned tensor. Default is None.out (
Optional
[Container
], default:None
) – optional output array, for writing the result to.
- Return type:
Container
- Returns:
ret – The nanmean of the array elements in the input container.
Examples
>>> a = ivy.Container(x=ivy.array([[1, ivy.nan], [3, 4]]), y=ivy.array([[ivy.nan, 1, 2], [1, 2, 3]]) >>> a.nanmean() { x: 2.6666666666666665 y: 1.8 }