I have the following dataframe, I wish to add a new column called open_next_year.
This column will be selected by comparing two columns; fiscalYear + 1 and ticker. Then using the value from column open.
Original dataframe:
fiscalYear ticker open
2017 FINL 17.4880
2017 AAPL 17.4880
...
2016 FINL 16.4880
2016 AAPL 16.4880
2015 FINL 15.4880
2015 AAPL 15.4880
Desired dataframe:
fiscalYear ticker open open_next_year
2017 FINL 17.4880
2017 AAPL 17.4880
2016 FINL 16.4880 17.4880
2016 AAPL 16.4880 17.4880
2015 FINL 15.4880 16.4880
2015 AAPL 15.4880 16.4880
What is the pandas way to achieve this please?