Calling statistics functions from Scipy
Question:
This may well be completely trivial.
I want to call the spearmanr function from scipy: (the data are just examples)
import scipy
from numpy import *
Len = [2,3,5,7,2]
Pop = [5,2,6,3,2]
a = array(Len)
b = array(Pop)
print scipy.stats.spearmanr(a,b)
This generates the error:
AttributeError: 'module' object has no attribute 'spearmanr'
What am I doing wrong?
Thanks
Answers:
Use import scipy.stats
. Then it works. Importing a package does not automatically import all the subpackages/modules. In these cases you have to do this explicitly.
This may well be completely trivial.
I want to call the spearmanr function from scipy: (the data are just examples)
import scipy
from numpy import *
Len = [2,3,5,7,2]
Pop = [5,2,6,3,2]
a = array(Len)
b = array(Pop)
print scipy.stats.spearmanr(a,b)
This generates the error:
AttributeError: 'module' object has no attribute 'spearmanr'
What am I doing wrong?
Thanks
Use import scipy.stats
. Then it works. Importing a package does not automatically import all the subpackages/modules. In these cases you have to do this explicitly.