[英]Python: correlation co-efficient between two sets of data
How would I calculate the correlation coefficient using Python between the spring training wins column and the regular-season wins column?如何使用 Python 计算春季训练获胜列和常规赛获胜列之间的相关系数?
Name![]() |
Spr.TR![]() |
Reg Szn![]() |
---|---|---|
Team B ![]() |
0.429 ![]() |
0.586 ![]() |
Team C ![]() |
0.417 ![]() |
0.646 ![]() |
Team D ![]() |
0.569 ![]() |
0.6 ![]() |
Team E ![]() |
0.569 ![]() |
0.457 ![]() |
Team F ![]() |
0.533 ![]() |
0.563 ![]() |
Team G ![]() |
0.724 ![]() |
0.617 ![]() |
Team H ![]() |
0.5 ![]() |
0.64 ![]() |
Team I![]() |
0.577 ![]() |
0.649 ![]() |
Team J ![]() |
0.692 ![]() |
0.466 ![]() |
Team K ![]() |
0.5 ![]() |
0.477 ![]() |
Team L ![]() |
0.731 ![]() |
0.699 ![]() |
Team M ![]() |
0.643 ![]() |
0.588 ![]() |
Team N ![]() |
0.448 ![]() |
0.531 ![]() |
If we assume that your data is in a variable of type pandas.DataFrame named df.如果我们假设您的数据位于名为 df 的 pandas.DataFrame 类型的变量中。
from scipy.stats.stats import pearsonr
correlation = pearsonr(df["Spr.TR"].tolist(),df["Reg Szn"].tolist())[0]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.