For a deeper look into our Eikon Data API, look into:

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
7 2 1 3

Unable to calculate CAGR for total return extracted from Eikon API

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, '')

eikoneikon-data-apiworkspaceworkspace-data-apirefinitiv-dataplatform-eikonpythondata
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

1 Answer

Upvotes
Accepted
4.6k 26 7 22

@deepika.naga.k this is not an Eikon issue, but a general pandas question. If you still would like some assistance, I will need the contents TSR_ric_list_1.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Click below to post an Idea Post Idea