corr() 函数的问题:nan 产生
Problem with corr() function: nan produced
我有以下代码:
Correlation = Deaths['Cases'].corr(COVID19['Cases'],method='pearson')
print(Correlation)
这给了我输出:
nan
我不明白这是为什么!谁能帮我一把?
总而言之,我想看看这两个系列之间是否存在相关性。
系列死亡['Cases']看起来像这样:
242 803
243 732
244 414
Name: Cases, dtype: int64
系列 COVID19['Cases'] 看起来像这样:
0 966
1 59504
2 148969
Name: Cases, dtype: int64
你们的指数不同,所以无法计算相关性。
Deaths['Cases'].reset_index(drop=True).corr(COVID19['Cases'].reset_index(drop=True), method='pearson')
#-0.9733651275536442
我有以下代码:
Correlation = Deaths['Cases'].corr(COVID19['Cases'],method='pearson')
print(Correlation)
这给了我输出:
nan
我不明白这是为什么!谁能帮我一把? 总而言之,我想看看这两个系列之间是否存在相关性。
系列死亡['Cases']看起来像这样:
242 803
243 732
244 414
Name: Cases, dtype: int64
系列 COVID19['Cases'] 看起来像这样:
0 966
1 59504
2 148969
Name: Cases, dtype: int64
你们的指数不同,所以无法计算相关性。
Deaths['Cases'].reset_index(drop=True).corr(COVID19['Cases'].reset_index(drop=True), method='pearson')
#-0.9733651275536442