Find correlation between columns whose names are specified as values in another dataframe
<p>I have two dataframes, one is a list of pairs of individuals, similar to below (but with about 150 pairs): </p>

<pre><code>ID_1   ID_2
X14567  X26789
X12637 X34560
X67495 X59023
</code></pre>

<p>The other dataframe consists of once column per individual with numerical values relating to that individuals underneath. All told about 300 columns and 300 rows. For example:</p>

<pre><code>X14567  X12637  X26789  X67495  X34560  X59023
0.41    0.29    0.70    0.83    0.41    0.30
0.59    0.44    0.20    0.94    0.03    0.97
0.48    0.91    0.78    0.92    0.40    0.09
0.07    0.21    0.42    0.14    0.96    0.96
0.33    0.13    0.53    0.04    0.52    0.49
0.94    0.28    0.37    0.26    0.11    0.09
</code></pre>

<p>I want to find the correlation of these values between each pair of individuals. to end up with something like:</p>

<pre><code>ID_1       ID_2    Correlation
X14567     X26789      -0.25
X12637     X34560      -0.25
X67495     X59023      -0.11
</code></pre>

<p>Is there a way that I can pull the values from the first dataframe to specify the name of the two columns that I need to find correlations between in such a way that can be easily repeated for each row of the first dataframe?</p>

<p>Many thanks for your help</p>