Python | Numpy nanmedian() function Last Updated : 20 Jun, 2022 Comments Improve Suggest changes Like Article Like Report numpy.nanmedian() function can be used to calculate the median of array ignoring the NaN value. If array have NaN value and we can find out the median without effect of NaN value. Let's see different type of examples about numpy.nanmedian() method. Syntax: numpy.nanmedian(a, axis=None, out=None, overwrite_input=False, keepdims=)Parameters: a: [arr_like] input array axis: we can use axis=1 means row wise or axis=0 means column wise. out: output 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: It return median in ndarray. Example #1: Python3 # Python code to demonstrate the # use of numpy.nanmedian import numpy as np # create 2d array with nan value. arr = np.array([[12, 10, 34], [45, 23, np.nan]]) print("Shape of array is", arr.shape) print("Median of array without using nanmedian function:", np.median(arr)) print("Using nanmedian function:", np.nanmedian(arr)) Output: Shape of array is (2, 3) Median of array without using nanmedian function: nan Using nanmedian function: 23.0 Example #2: Python3 # Python code to demonstrate the # use of numpy.nanmedian # with axis import numpy as np # create 2d array with nan value. arr = np.array([[12, 10, 34], [45, 23, np.nan]]) print("Shape of array is", arr.shape) print("Median of array with axis = 0:", np.median(arr, axis = 0)) print("Using nanmedian function:", np.nanmedian(arr, axis = 0)) Output: Shape of array is (2, 3) Median of array with axis = 0: [ 28.5 16.5 nan] Using nanmedian function: [ 28.5 16.5 34. ] Example #3: Python3 # Python code to demonstrate the # use of numpy.nanmedian # with axis = 1 import numpy as np # create 2d matrix with nan value arr = np.array([[12, 10, 34], [45, 23, np.nan], [7, 8, np.nan]]) print("Shape of array is", arr.shape) print("Median of array with axis = 0:", np.median(arr, axis = 1)) print("Using nanmedian function:", np.nanmedian(arr, axis = 1)) Output: Shape of array is (3, 3) Median of array with axis = 0: [ 12. nan nan] Using nanmedian function: [ 12. 34. 7.5] Comment More infoAdvertise with us Next Article Python | Numpy nanmedian() function S shrikanth13 Follow Improve Article Tags : Technical Scripter Python Python-numpy Python numpy-Statistics Functions Practice Tags : python Similar Reads Python | numpy.nanmean() function numpy.nanmean() function can be used to calculate the mean of array ignoring the NaN value. If array have NaN value and we can find out the mean without effect of NaN value. Syntax: numpy.nanmean(a, axis=None, dtype=None, out=None, keepdims=))Parameters: a: [arr_like] input array axis: we can use ax 2 min read numpy.nanstd() function - Python numpy.nanstd() function compute the standard deviation along the specified axis, while ignoring NaNs. Syntax : numpy.nanstd(arr, axis = None, dtype = None, out = None, ddof = 0, keepdims) Parameters : arr : [array_like] Calculate the standard deviation of the non-NaN values. axis : [{int, tuple of i 2 min read numpy.nanmin() in Python numpy.nanmin()function is used when to returns minimum value of an array or along any specific mentioned axis of the array, ignoring any Nan value. Syntax : numpy.nanmin(arr, axis=None, out=None) Parameters : arr :Input array. axis :Axis along which we want the min value. Otherwise, it will consider 2 min read Numpy MaskedArray.median() function | Python numpy.MaskedArray.median() function is used to compute the median along the specified axis of a masked array.It returns the median of the array elements. Syntax : numpy.ma.median(arr, axis=None, out=None, overwrite_input=False, keepdims=False) Parameters: arr : [ ndarray ] Input masked array. axis : 3 min read numpy.pad() function in Python numpy.pad() function is used to pad the Numpy arrays. Sometimes there is a need to perform padding in Numpy arrays, then numPy.pad() function is used. The function returns the padded array of rank equal to the given array and the shape will increase according to pad_width. Syntax: numpy.pad(array, p 2 min read numpy.ma.make_mask() function | Python numpy.ma.make_mask() function is used to create a boolean mask from an array. This function can accept any sequence that is convertible to integers, or nomask. It does not require that contents must be 0s and 1s, values of 0 are interpreted as False, everything else as True. Return m as a boolean ma 2 min read numpy.mask_indices() function | Python numpy.mask_indices() function return the indices to access (n, n) arrays, given a masking function. Syntax : numpy.mask_indices(n, mask_func, k = 0) Parameters : n : [int] The returned indices will be valid to access arrays of shape (n, n). mask_func : [callable] A function whose call signature is s 1 min read numpy.nanargmin() in Python The numpy.nanargmin() function returns indices of the min element of the array in a particular axis ignoring NaNs. The results cannot be trusted if a slice contains only NaNs and Infs. Syntax:  numpy.nanargmin(array, axis = None) Parameters : array : Input array to work on axis : [int, optional]A 2 min read numpy.ma.fix_invalid() function | Python numpy.ma.fix_invalid() function return input with invalid data masked and replaced by a fill value. Where invalid data means values of nan, inf, etc. Syntax : numpy.ma.fix_invalid(arr, mask = False, copy = True, fill_value = None) Parameter : arr : [array_like] Input array. mask : [sequence, optiona 2 min read numpy.ma.filled() function - Python numpy.ma.filled() function return input as an array with masked data replaced by a fill value. If arr is not a MaskedArray, arr itself is returned. If arr is a MaskedArray and fill_value is None, fill_value is set to arr.fill_value. Syntax : numpy.ma.filled(arr, fill_value = None) Parameters : arr : 1 min read Like