I have the following correlation matrix:
symbol abc xyz ghj
symbol
abc 1 0.1 -0.2
xyz 0.1 1 0.3
ghj -0.2 0.3 1
I need to be able to find the standard deviation for the whole dataframe but that has to exclude the perfect correlation values, ie: the standard deviation must not take into account abc:abc, xyz:xyz, ghj:ghj
I am able to get the standard deviation for the entire dataframe using:
df.stack().std()
But this takes into account every single value which is not correct. The standard deviation should not include row/column combinations where an item is being correlated to itself (ie: 1). Is there a way to remove abc:abc, xyz:xyz, ghj:ghj. Then calculate the standard deviation.
Perhaps converting it to a dict or something?