Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

module 'scipy.stats' has no attribute 'nanmean'

I'm getting the error mentioned in the title. I have all of the following three imports in my code:

import scipy as sc
import scipy.stats
from scipy import stats

But still get the error. I'm sure it has something to do with the version, but can't figure out either how to make it work or a workaround for "nanmean". Any suggestions would be appreciated.

like image 770
swabygw Avatar asked Dec 03 '16 04:12

swabygw


2 Answers

nanmean was a deprecated function that was removed from scipy.stats in version 0.18.0. You will have to either use an older version of SciPy or use the equivalent function from NumPy.

from numpy import nanmean
like image 159
Kevin Schellenberg Avatar answered Oct 20 '22 09:10

Kevin Schellenberg


nanmean is also available from scipy module itself, so this might work if you replace

from scipy.stats import nanmean

with

from scipy import nanmean
like image 40
Edwin Pozharski Avatar answered Oct 20 '22 10:10

Edwin Pozharski