Currently i have dataframe which has has stock ticker and return
ticker_name return
"AAPL 2020" -15%
"AAPL 2019" 20%
"AAPL 2018" 40%
"AAPL 2017" 30%
"AAPL 2016" -10%
....
I also have the data of index return in yearly format for the last x years.With this data want to tag if specific stock have above market return
sp_500_year return
"2020" -30%
"2019" 10%
"2018" 10%
"2017" 10%
"2016" 20%
....
Expected output are new column which are tags in boolean format. 1 if they have above market return , and 0 if they underperform the market.
ticker_name return above_market
"AAPL 2020" -15% 1
"AAPL 2019" 20% 1
"AAPL 2018" 40% 1
"AAPL 2017" 30% 1
"AAPL 2016" -10% 0
....
I found a similar question to mine, however this question is comparing strings and only have two possible input (BULL & BEAR) while mine is float and vary (index return).
Pandas: if row in column A contains "x", write "y" to row in column B