I have a data frame consisting of thousands of stock quotes, ordered by symbol(tic) and Date.
Date tic prccd
0 1-1-20 AAPL 4.00
1 2-1-20 AAPL 4.10
2 3-1-20 AAPL 4.12
3 1-1-20 MSFT 6.00
4 2-1-20 MSFT 6.15
5 3-1-20 MSFT 6.10
With
stocks_data['log_return'] = np.log(1 + stocks_data.groupby('tic')['prccd'].pct_change())
I aim to get the logarithmic daily return of these stocks. Does the numpy function acknowledge the groupby tic operation?