I have a dataframe containing m series of stock prices for different companies like the one below:
Date Stock 1 Stock 2 Stock 3 ... Stock m
1 100 200 300 ... 500
2 500 300 200 ... 100
: : : : ... :
n 200 300 400 ... 100
What I need to do is find out which of the m stocks has the highest variance and then swap it with the entries of Stock 1. Assume that in the above example Stock 3 is the one with the highest variance, the final output should then be:
Date Stock 3 Stock 2 Stock 1 ... Stock m
1 300 200 100 ... 500
2 200 300 500 ... 100
: : : : ... :
n 400 300 200 ... 100
In order to find the column with highest variance I tried computing:
print(max(df.var()))
However, this only yields the amount of variance without printing the stock ticker. How can I fix this?