Stack Overflow for Teams A private, secure home for your team’s questions and forex zero sum game. M9 1a8 8 0 1 0 0 16A8 8 0 0 0 9 1zm. I am looking for a function that takes as input two lists, and returns the Pearson correlation, and the significance of the correlation. You can have a look at scipy.
Help on function pearsonr in module scipy. Calculates a Pearson correlation coefficient and the p-value for testing non-correlation. The Pearson correlation coefficient measures the linear relationship between two datasets. Strictly speaking, Pearson’s correlation requires that each dataset be normally distributed.
How about correlation coefficient of two dictionaries ? 702846 Pearson correlation is defined on a 2xN matrix. There is no generally applicable method that converts two dictionaries into a 2xN matrix, but you might use the array of pairs of dictionary values corresponding to the keys of the intersection of the keys of your dictionaries. The Pearson correlation can be calculated with numpy’s corrcoef. Works – but quite confusing output. Great answer – by far the most informative.
Also works with a two-row pandas. I think it’s because imap cannot handle float. Just as a comment, consider that libraries as scipy et al are developed by people knowing a lot of numerical analysis. Beware of the type of the variables! Your code won’t work for cases like: , or ,. The correlation coefficient is not defined for any of those cases. Putting them into R returns “NA” for all three.