I want to calculate the cumulative returns based on prices for each stock in a pandas dataframe. the cumulative return is current day price - price at the beginning of time (first row )in the data frame -1. How can we get this in one line ?
My dataframe is like this -
date, stock price1 , stock price2, stock_price3 and so on.
NSE ITC
2012-12-24 5855.750000 169.398026
2012-12-26 5905.600098 171.433975
2012-12-27 5870.100098 170.194687
2012-12-28 5908.350098 170.784225
2012-12-31 5905.100098 169.250168
i need a generic solution that I can execute and get a result in one line.