[SciPy-User] nan's in stats.spearmanr

Ben benwhalley@gmail....
Wed Apr 4 14:54:41 CDT 2012


Apologies if this seems obvious to others, but I'm using both functions from 
pandas and stats.spearmanr in different bits of my code and noticed something 
odd.  Is the following output expected?

from  pandas import DataFrame
from scipy import stats
a = [1, nan, 2]
b = [1, 2, 2]       
df = DataFrame(zip(a,b))
stats.spearmanr(a,b)

gives: (0.86602540378443871, 0.3333333333333332)

df.corr(method="spearman")
   0  1
0  1  1
1  1  1  

Removing the nan from a produces identical results. I had expected the first
output, but perhaps I'm not  understanding how scipy likes to handle nan.

Any advice much appreciated.

Regards,

Ben



More information about the SciPy-User mailing list