I have a dataframe df:
ID Var1 Var2
1 1.2 4
1 2.1 6
1 3.0 7
2 1.3 8
2 2.1 9
2 3.2 13
I want to find the pearson correlation coefficient value between Var1 and Var2 for every ID
So the result should look like this:
ID Corr_Coef
1 0.98198
2 0.97073
update:
Must make sure all columns of variables are int or float