Category  SubCategory  Month  Value
A         A1           Jan     1
A         A1           Feb     2
A         A1           Mar     3
A         A2           Jan     2
A         A2           Feb     3
A         A2           Mar     5
B         B1           Jan     1
B         B1           Feb     6
B         B1           Mar     7
B         B2           Jan     3
B         B2           Feb     6
B         B2           Mar     7
I have a sample pandas df like this. I would like to compute the correlation coefficient between Subgroup Categories A1 and A2, B1 and B2, but not A1 and B1 etc. My end goal is to have a table such as this:
    A1        A2        B1     B2
A1  1.0000  0.9820      
A2  0.9820  1.0000      
B1                    1.0000    0.9963
B2                    0.9963    1.0000
Can anyone help me with python code?
Obviously this one gives me a corr value of 1 for each SubCategory
df.groupby('SubCategory').corr()
 
     
    