You pretty much sorted out all the parts, you just need to combine them:
In [441]: df.groupby('ID')[['Val1','Val2']].corr() Out[441]: Val1 Val2 ID A Val1 1.000000 0.500000 Val2 0.500000 1.000000 B Val1 1.000000 0.385727 Val2 0.385727 1.000000
In your case, a 2x2 printout for each identifier is overly detailed. I don't see the ability to print scalar correlation instead of the entire matrix, but you can do something like:
In [442]:df.groupby('ID')[['Val1','Val2']].corr().ix[0::2,'Val2'] Out[442]: ID A Val1 0.500000 B Val1 0.385727
And then rename and save things as you like.
source share