corr()函数的问题:产生了楠。

问题描述 投票:0回答:1

我有下面的代码。

Correlation = Deaths['Cases'].corr(COVID19['Cases'],method='pearson')
print(Correlation)

它给我的输出是:

nan

我不明白为什么会这样!谁能给我一个帮助?总之,我想看看这两个序列之间是否有相关性。

该系列 死亡['案件'] 看起来像这样。

242    803
243    732
244    414
Name: Cases, dtype: int64

这个系列 COVID19['案件'] 看起来是这样的。

0       966
1     59504
2    148969
Name: Cases, dtype: int64
python pandas statistics correlation series
1个回答
1
投票

你们的指数不同,所以不能计算相关性。

Deaths['Cases'].reset_index(drop=True).corr(COVID19['Cases'].reset_index(drop=True), method='pearson')
#-0.9733651275536442
© www.soinside.com 2019 - 2024. All rights reserved.