The numpy.nanmean () function can be used to compute the average of an array ignoring the NaN value. If the array is NaN and we can know the average without being influenced by the NaN value.
Syntax: numpy.nanmean (a, axis = None, dtype = None, out = None, keepdims =))
a: [arr_like] input array
axis : we can use axis = 1 means row wise or axis = 0 means column wise.
out: output array
dtype: data types of array
overwrite_input: If True, then allow use of memory of input array a for calculations. The input array will be modified by the call to median.
keepdims: 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.
Returns: Returns the average of the array elements
Example # 1:
Shape of array is (2, 3) Mean of array without using nanmean function: nan Using nanmean function: 26.4
Example # 2:
Shape of array is (4, 3) Mean of array with axis = 0: [26.5 29.75 nan] Using nanmedian function: [26.5 29.75 16.5]
Example # 3: