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

Asked By: WillJones

||

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.

Answered By: Björn Pollex
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.