Visualizing Time Series Data in Python
Thomas Vincent
Head of Data Science, Getty Images
from scipy.stats.stats import pearsonr
from scipy.stats.stats import spearmanr
from scipy.stats.stats import kendalltau
x = [1, 2, 4, 7]
y = [1, 3, 4, 8]
pearsonr(x, y)
SpearmanrResult(correlation=0.9843, pvalue=0.01569)
spearmanr(x, y)
SpearmanrResult(correlation=1.0, pvalue=0.0)
kendalltau(x, y)
KendalltauResult(correlation=1.0, pvalue=0.0415)
x y z
x 1.00 -0.46 0.49
y -0.46 1.00 -0.61
z 0.49 -0.61 1.00
corr_p = meat[['beef', 'veal','turkey']].corr(method='pearson')
print(corr_p)
beef veal turkey
beef 1.000 -0.829 0.738
veal -0.829 1.000 -0.768
turkey 0.738 -0.768 1.000
corr_s = meat[['beef', 'veal','turkey']].corr(method='spearman')
print(corr_s)
beef veal turkey
beef 1.000 -0.812 0.778
veal -0.812 1.000 -0.829
turkey 0.778 -0.829 1.000
corr_mat = meat.corr(method='pearson')
import seaborn as sns
sns.heatmap(corr_mat)
sns.clustermap(corr_mat)
Visualizing Time Series Data in Python