Hi. I need to take a median in a 3d array on axis=0 but I would like to ignore a bunch of nan-values that are in the array.

right now I have just been using np.median(x, axis=0) ...but this sometimes gives me a median value of nan which I can't have for later in the program.


Is there way to take the median while ignoring the nans?

Also, (keep in mind I am rather new to programming) I did find that scipy.stats had a nanmedian function that would do what I need. I have scipy on my computer but when I go to import scipy.stats I get an import error.

Do I need to install scipy.stats or something? I kinda figured that it would have come with the scipy??

I wasn't the one that installed anything python related on my computer so I don't exactly know how it all works.


Any help would be appreciated!