In NumPy versions <= 1.9.0 Nan is returned for slices that are all-NaN or empty. numpy.nanmedian. In this method, we will calculate our weighted average and create a numpy array. Python | Numpy nanmedian() function - GeeksforGeeks Let df, be your dataset, and mylist the list with the values you want to add to the dataframe.. Let's suppose you want to call your new column simply, new_column First make the list into a Series: If the numpy array has a NaN value and we can easily find out the average without the effect of the NaN value. Ignore NaN from Mean. The mean is normally calculated as x.sum () / N, where N = len (x) . So firstly, I suggest that … ndarray, see dtype parameter above. However, np.average doesn't ignore NaN like np.nanmean does, so my first 5 entries of each row are included in the latitude averaging and make the entire time series full of NaN. Is there a way I can take a weighted average without the NaN's being included in the calculation? The average is taken over the flattened array by default, otherwise over the specified axis. Compute the arithmetic mean along the specified axis, ignoring NaNs. NaN is used to representing entries that are undefined. In [47]: c = np.outer(a,b) In [54]: c.shape. nanstd (a, axis=None, dtype=None, out=None, ddof=0, keepdims=