I am having trouble trying to figure out how to do this in Python. I have created it in Excel, but I would like to automate this for any sector or grouping of sub-industries.
In this matrix, I set the diagonal as 1 since I am only worried about the average correlations between sub-industry.
I have done this for a few quarters but I am interested in automating this through Python. Data is from my Bloomberg Terminal.