I have a dataframe with Total Return for a few RICs
TSRdf_1_2002, e = ek.get_data(TSR_ric_list_1, ['TR.TotalReturn'],{'SDate':'2002-06-30', 'EDate':'2005-06-30'})
I am trying to calculate CAGr for this as follows:
TSRdf_1_2002['TSR_02_05'] = ((TSRdf_1_2002['Total Return']+100)/100)**(1/3)-1
Getting the following error:
TypeError: must be str, not int
I have tried these as well:
When trying to convert the dataframe column to numeric, I get
TSRdf_1_2002['TSR_02_05'] = pd.to_numeric(TSRdf_1_2002['Total Return'])
ValueError: Unable to parse string "NaN" at position 853
Tried to replace the NaNs, the line gets executed but continue to get the parse string error above
TSRdf_1_2002 = TSRdf_1_2002.replace(np.nan, '')