Issue
Example
a1 = [1,2,3,4,5]
a2 = [2,3,5,6]
How to calculate correlation coefficient of this types of columns
Solution
Trimming the lists to a common length and using numpy.corrcoeff
:
a1 = [1,2,3,4,5]
a2 = [2,3,5,6]
n = min(len(a1), len(a2))
r = np.corrcoef(a1[:n], a2[:n])[0, 1]
Output: 0.9899494936611666
Answered By - mozway
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.