def pearson(x,y):
xmean=mean(x,axis=0)
ymean=mean(y,axis=0)
covxy=dot((x-xmean).T,y-ymean)
xvar=dot((x-xmean).T,x-xmean)
yvar=dot((y-ymean).T,y-ymean)
p=covxy/sqrt(xvar*yvar)
print(p)
def main():
df = pd.read_excel(r'C:\Users\83989\Desktop\模拟赛\每月书籍销售表.xlsx')
pearson(df['销售码洋'], df['支出'])
if __name__=='__main__':
main()
05-18
11万+
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
04-02
3万+
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
02-04
02-04