This is a pretty hard question to me. The answer might come simply to fresh eyes, but I'm stuck. Basically, I have a dataframe of bulk balance sheets from simfin.com. I want to get the percent change in the Retained Earnings
column, but restart the accumulation at each new ticker.
Ticker Fiscal Year Fiscal Period Retained Earnings
0 A 2016 Q1 5.666000e+09
1 A 2016 Q2 5.720000e+09
2 A 2016 Q3 6.000000e+09
3 A 2016 Q4 6.089000e+09
4 A 2017 Q1 -4.530000e+08
... ... ... ... ...
36669 ZYXI 2019 Q3 1.140900e+07
36670 ZYXI 2019 Q4 1.435600e+07
36671 ZYXI 2020 Q1 1.729300e+07
36672 ZYXI 2020 Q2 2.031000e+07
36673 ZYXI 2020 Q3 2.164300e+07
How would I do that?